@combeenation/3d-viewer 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +111 -0
- package/dist/types/api/classes/animationInterface.d.ts +8 -0
- package/dist/types/api/classes/dottedPath.d.ts +79 -0
- package/dist/types/api/classes/element.d.ts +153 -0
- package/dist/types/api/classes/event.d.ts +396 -0
- package/dist/types/api/classes/eventBroadcaster.d.ts +26 -0
- package/dist/types/api/classes/fuzzyMap.d.ts +7 -0
- package/dist/types/api/classes/parameter.d.ts +351 -0
- package/dist/types/api/classes/parameterObservable.d.ts +36 -0
- package/dist/types/api/classes/parameterizable.d.ts +15 -0
- package/dist/types/api/classes/placementAnimation.d.ts +45 -0
- package/dist/types/api/classes/variant.d.ts +253 -0
- package/dist/types/api/classes/variantInstance.d.ts +53 -0
- package/dist/types/api/classes/variantParameterizable.d.ts +17 -0
- package/dist/types/api/classes/viewer.d.ts +200 -0
- package/dist/types/api/classes/viewerLight.d.ts +66 -0
- package/dist/types/api/internal/lensRendering.d.ts +8 -0
- package/dist/types/api/internal/sceneSetup.d.ts +13 -0
- package/dist/types/api/manager/animationManager.d.ts +30 -0
- package/dist/types/api/manager/gltfExportManager.d.ts +78 -0
- package/dist/types/api/manager/sceneManager.d.ts +33 -0
- package/dist/types/api/manager/tagManager.d.ts +108 -0
- package/dist/types/api/manager/textureLoadManager.d.ts +22 -0
- package/dist/types/api/manager/variantInstanceManager.d.ts +103 -0
- package/dist/types/api/store/specStorage.d.ts +32 -0
- package/dist/types/api/util/babylonHelper.d.ts +235 -0
- package/dist/types/api/util/globalTypes.d.ts +436 -0
- package/dist/types/api/util/resourceHelper.d.ts +58 -0
- package/dist/types/api/util/sceneLoaderHelper.d.ts +44 -0
- package/dist/types/api/util/stringHelper.d.ts +13 -0
- package/dist/types/api/util/structureHelper.d.ts +9 -0
- package/dist/types/declaration.tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +27 -0
- package/package.json +87 -0
- package/src/api/classes/animationInterface.ts +10 -0
- package/src/api/classes/dottedPath.ts +181 -0
- package/src/api/classes/element.ts +731 -0
- package/src/api/classes/event.ts +452 -0
- package/src/api/classes/eventBroadcaster.ts +52 -0
- package/src/api/classes/fuzzyMap.ts +21 -0
- package/src/api/classes/parameter.ts +554 -0
- package/src/api/classes/parameterObservable.ts +73 -0
- package/src/api/classes/parameterizable.ts +87 -0
- package/src/api/classes/placementAnimation.ts +162 -0
- package/src/api/classes/variant.ts +933 -0
- package/src/api/classes/variantInstance.ts +123 -0
- package/src/api/classes/variantParameterizable.ts +85 -0
- package/src/api/classes/viewer.ts +742 -0
- package/src/api/classes/viewerLight.ts +339 -0
- package/src/api/internal/debugViewer.ts +90 -0
- package/src/api/internal/lensRendering.ts +9 -0
- package/src/api/internal/sceneSetup.ts +205 -0
- package/src/api/manager/animationManager.ts +143 -0
- package/src/api/manager/gltfExportManager.ts +236 -0
- package/src/api/manager/sceneManager.ts +136 -0
- package/src/api/manager/tagManager.ts +451 -0
- package/src/api/manager/textureLoadManager.ts +95 -0
- package/src/api/manager/variantInstanceManager.ts +298 -0
- package/src/api/store/specStorage.ts +68 -0
- package/src/api/util/babylonHelper.ts +822 -0
- package/src/api/util/globalTypes.ts +503 -0
- package/src/api/util/resourceHelper.ts +191 -0
- package/src/api/util/sceneLoaderHelper.ts +170 -0
- package/src/api/util/stringHelper.ts +30 -0
- package/src/api/util/structureHelper.ts +49 -0
- package/src/buildinfo.json +3 -0
- package/src/dev.ts +62 -0
- package/src/index.ts +79 -0
- package/src/types.d.ts +36 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { PBRMaterial } from '@babylonjs/core/Materials/PBR/pbrMaterial';
|
|
2
|
+
import { IExportOptions } from '@babylonjs/serializers/glTF/2.0';
|
|
3
|
+
export declare class GltfExportManager {
|
|
4
|
+
protected viewer: Viewer;
|
|
5
|
+
static readonly UNIQUE_MESH_METADATA_PROPERTY = "originalName";
|
|
6
|
+
/**
|
|
7
|
+
* Constructor.
|
|
8
|
+
*/
|
|
9
|
+
protected constructor(viewer: Viewer);
|
|
10
|
+
/**
|
|
11
|
+
* Creates an {@link GltfExportManager}.
|
|
12
|
+
*/
|
|
13
|
+
static create(viewer: Viewer): Promise<GltfExportManager>;
|
|
14
|
+
/**
|
|
15
|
+
* Exports selected nodes to a file.
|
|
16
|
+
* @param filename optional name of the exported .GLB file.
|
|
17
|
+
* @param exportOptions export options to be merged with default options.\
|
|
18
|
+
* `exportOptions.createUniqueMeshNames` defaults to `true` if not given.
|
|
19
|
+
* @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export
|
|
20
|
+
*/
|
|
21
|
+
exportGlb(filename?: string, { createUniqueMeshNames, ...exportOptionsRest }?: IExportOptionsExtended, excluded?: ExcludedGeometryList): Promise<File | undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* Exports selected nodes to GLTF. This may result in more than one file, since textures are exported separately.
|
|
24
|
+
* @param filename name of the main (text-based) .GLTF file referring to separate texture files.
|
|
25
|
+
* @param exportOptions export options to be merged with default options.\
|
|
26
|
+
* `exportOptions.createUniqueMeshNames` defaults to `true` if not given.
|
|
27
|
+
* @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export
|
|
28
|
+
*/
|
|
29
|
+
exportGltfToFile(filename: string, { createUniqueMeshNames, ...exportOptionsRest }?: IExportOptionsExtended, excluded?: ExcludedGeometryList): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Exports selected nodes to GLB. This results in one binary file.
|
|
32
|
+
* @param filename name of the .GLB file.
|
|
33
|
+
* @param exportOptions export options to be merged with default options.\
|
|
34
|
+
* `exportOptions.createUniqueMeshNames` defaults to `true` if not given.
|
|
35
|
+
* @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export
|
|
36
|
+
*/
|
|
37
|
+
exportGlbToFile(filename: string, { createUniqueMeshNames, ...exportOptionsRest }?: IExportOptionsExtended, excluded?: ExcludedGeometryList): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Gets predefined {@link IExportOptionsExtended } merged with given ones.
|
|
40
|
+
*/
|
|
41
|
+
protected gltfExportOptions(mergeWithOptions?: IExportOptionsExtended, excluded?: ExcludedGeometryList): IExportOptions;
|
|
42
|
+
/**
|
|
43
|
+
* Stuff to be done before exporting to GLTF
|
|
44
|
+
*/
|
|
45
|
+
protected exportPreProcess({ createUniqueMeshNames }: IExportOptionsExtended): void;
|
|
46
|
+
/**
|
|
47
|
+
* Stuff to be done after the GLTF export
|
|
48
|
+
*/
|
|
49
|
+
protected exportPostProcess(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Materials with refraction set are not exported properly.
|
|
52
|
+
* Exchange all such (relevant) materials with a more export-friendly version
|
|
53
|
+
*/
|
|
54
|
+
protected exchangeRefractionMaterials(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Restore original materials with set refraction.
|
|
57
|
+
*/
|
|
58
|
+
protected restoreRefractionMaterials(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Create an export-friendly replacement material for a material using refraction.
|
|
61
|
+
* @param mat Material to be replaced
|
|
62
|
+
*/
|
|
63
|
+
protected createRefractionMaterialReplacement(mat: PBRMaterial): PBRMaterial;
|
|
64
|
+
/**
|
|
65
|
+
* Inspect if a material was temporarily cloned for GLB export
|
|
66
|
+
* @param mat Material to be inspected
|
|
67
|
+
*/
|
|
68
|
+
protected isMaterialClonedForExport(mat: PBRMaterial): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Set unique mesh names for GLB export
|
|
71
|
+
*/
|
|
72
|
+
protected setUniqueMeshNames(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Restore original mesh names for meshes that were
|
|
75
|
+
* renamed with {@link setUniqueMeshNames()}
|
|
76
|
+
*/
|
|
77
|
+
protected restoreOriginalMeshNames(): void;
|
|
78
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ParameterObservable } from '../classes/parameterObservable';
|
|
2
|
+
import { TextureLoadManager } from './textureLoadManager';
|
|
3
|
+
import { Camera } from '@babylonjs/core/Cameras/camera';
|
|
4
|
+
import { Scene as BabylonScene } from '@babylonjs/core/scene';
|
|
5
|
+
export declare class SceneManager extends ParameterObservable {
|
|
6
|
+
scene: BabylonScene;
|
|
7
|
+
protected readonly _parameterObservers: Map<string, ParameterObserver[]>;
|
|
8
|
+
protected _textureLoadManager: TextureLoadManager | null;
|
|
9
|
+
/**
|
|
10
|
+
* Constructor.
|
|
11
|
+
*/
|
|
12
|
+
protected constructor(scene: BabylonScene);
|
|
13
|
+
/**
|
|
14
|
+
* Creates a {@link SceneManager} based on given Babylon.js scene.
|
|
15
|
+
*/
|
|
16
|
+
static create(scene: BabylonScene): Promise<SceneManager>;
|
|
17
|
+
/**
|
|
18
|
+
* The active `Camera`.
|
|
19
|
+
*/
|
|
20
|
+
get activeCamera(): Camera;
|
|
21
|
+
/**
|
|
22
|
+
* Places the given {@link ParameterBag} in the {@link SceneManager}'s parameters, replaces all patterns in the
|
|
23
|
+
* {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
|
|
24
|
+
*
|
|
25
|
+
* @emit {@link Event.SCENE_PARAMETER_COMMITTED}
|
|
26
|
+
*/
|
|
27
|
+
commitParameters(parameters?: ParameterBag): Promise<SceneManager>;
|
|
28
|
+
protected addParameterObservers(): SceneManager;
|
|
29
|
+
/**
|
|
30
|
+
* Bootstrapping for parameters. It sets the `parametersInitialized` to true for all ancestors.
|
|
31
|
+
*/
|
|
32
|
+
protected bootstrapParameters(parameters?: ParameterBag): Promise<SceneManager>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
|
|
2
|
+
export declare class TagManager {
|
|
3
|
+
protected viewer: Viewer;
|
|
4
|
+
readonly parameters: TagManagerParameterBag;
|
|
5
|
+
readonly parameterObservers: TagManagerParameterObserverBag;
|
|
6
|
+
/**
|
|
7
|
+
* Constructor.
|
|
8
|
+
*/
|
|
9
|
+
constructor(viewer: Viewer);
|
|
10
|
+
/**
|
|
11
|
+
* Calls the {@link ParameterObserver} for given {@link Parameter} and applies the {@link ParameterValue} on all
|
|
12
|
+
* nodes with given tagName.
|
|
13
|
+
*/
|
|
14
|
+
setTagParameterValue(tagName: string, parameterName: string, value: ParameterValue): Promise<ParameterObserverResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Calls the {@link ParameterObserver} for given {@link Parameter} and applies the {@link ParameterValue} on all
|
|
17
|
+
* nodes with given nodeName.
|
|
18
|
+
*/
|
|
19
|
+
setNodeParameterValue(nodeName: string, parameterName: string, value: ParameterValue): Promise<ParameterObserverResult>;
|
|
20
|
+
/**
|
|
21
|
+
* Splits the passed {@link TagManagerParameterValue}s into individual values and calls all {@link ParameterObserver}s
|
|
22
|
+
* of all {@link Parameter}s with the respective {@link TagManagerSubject} and {@link ParameterValue}. The result is a
|
|
23
|
+
* map of passed {@link TagManagerParameterValue}s and the associated {@link ParameterObserverResult} of the
|
|
24
|
+
* {@link ParameterObserver}.
|
|
25
|
+
*/
|
|
26
|
+
setParameterValues(values: TagManagerParameterValue[]): Promise<Map<TagManagerParameterValue, ParameterObserverResult>>;
|
|
27
|
+
/**
|
|
28
|
+
* Gets a list of {@link TagManagerSubject}s that are present in both the state of the {@link TagManager}'s
|
|
29
|
+
* {@link parameters} and the given node.
|
|
30
|
+
*/
|
|
31
|
+
getSubjectsFor(node: TransformNode): TagManagerSubject[];
|
|
32
|
+
/**
|
|
33
|
+
* Gets a list of {@link TagManagerSubject}s that are present in both the state of the {@link TagManager}'s
|
|
34
|
+
* {@link parameters} and the given nodes.
|
|
35
|
+
*/
|
|
36
|
+
getApplicableSubjectsFor(nodes: TransformNode[]): TagManagerSubject[];
|
|
37
|
+
/**
|
|
38
|
+
* Applies all existing states of the {@link TagManager}'s {@link parameters} for given {@link TagManagerSubject}s.
|
|
39
|
+
*/
|
|
40
|
+
applyExistingParameterValuesFor(subjects: TagManagerSubject[]): Promise<Map<TagManagerSubject, ParameterObserverResult>>;
|
|
41
|
+
/**
|
|
42
|
+
* Does the same as {@link setParameterValues} with the difference that all existing states of the
|
|
43
|
+
* {@link TagManager}'s {@link parameters} are applied to all given nodes.
|
|
44
|
+
*/
|
|
45
|
+
applyExistingParameterValuesTo(nodes: TransformNode[]): Promise<Map<TagManagerSubject, ParameterObserverResult>>;
|
|
46
|
+
/**
|
|
47
|
+
* Applies all existing states of the {@link TagManager}'s {@link parameters} for all {@link TagManagerSubject}s.
|
|
48
|
+
*/
|
|
49
|
+
applyExistingParameterValues(): Promise<Map<TagManagerSubject, ParameterObserverResult>>;
|
|
50
|
+
/**
|
|
51
|
+
* Maps all tags on given nodes with the {@link TagMapping} and updates the state of the {@link TagManager}'s
|
|
52
|
+
* {@link parameters} for all new tags.
|
|
53
|
+
* Also updates the state of all nodes in the tag managers parameter state.
|
|
54
|
+
*/
|
|
55
|
+
mapNodesAndTags(nodes: TransformNode[], tagMapping: TagMapping): TagManager;
|
|
56
|
+
/**
|
|
57
|
+
* Prints the state of the {@link TagManager}'s {@link parameters} to the console.
|
|
58
|
+
*/
|
|
59
|
+
printAllTags(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Prints the state of the {@link TagManager}'s {@link parameters} for one tagName to the console.
|
|
62
|
+
*/
|
|
63
|
+
printTagInfo(tagName: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* Sets a {@link ParameterObserver} for the given {@link Parameter}.
|
|
66
|
+
*/
|
|
67
|
+
setParameterObserver(parameter: string, observer: TagManagerParameterObserver): TagManager;
|
|
68
|
+
/**
|
|
69
|
+
* Gets all nodes for given {@link TagManagerSubject} on the Babylon.js scene.
|
|
70
|
+
*/
|
|
71
|
+
getNodesBySubject(subject: TagManagerSubject, predicate?: (node: TransformNode) => boolean): TransformNode[];
|
|
72
|
+
/**
|
|
73
|
+
* Registers observers that are called on every new node added to the Babylon.js scene. The observers ensure that each
|
|
74
|
+
* new node gets the state of the {@link TagManager}'s {@link parameters} applied.
|
|
75
|
+
*/
|
|
76
|
+
registerNewTransformNodeObservers(scene: Scene): void;
|
|
77
|
+
/**
|
|
78
|
+
* Adds the default {@link ParameterObserver}s.
|
|
79
|
+
* @protected
|
|
80
|
+
*/
|
|
81
|
+
protected addParameterObservers(): TagManager;
|
|
82
|
+
/**
|
|
83
|
+
* Passes all {@link ParameterValue}s of the given {@link ParameterBag} for given {@link TagManagerSubject} to
|
|
84
|
+
* {@link handleParameter}.
|
|
85
|
+
* @protected
|
|
86
|
+
*/
|
|
87
|
+
protected handleParameterBag(subject: TagManagerSubject, parameters: ParameterBag): Promise<ParameterObserver>[];
|
|
88
|
+
/**
|
|
89
|
+
* Asserts the given {@link Parameter} and its {@link ParameterValue}, stores the state in the {@link TagManager}'s
|
|
90
|
+
* {@link parameters}, calculates the applicable nodes, injects the {@link ParameterValue} in the node's metadata,
|
|
91
|
+
* calls the responsible {@link ParameterObserver}s and emits the event {@link Event.TAG_MANAGER_PARAMETER_COMMITTED}.
|
|
92
|
+
* @protected
|
|
93
|
+
*/
|
|
94
|
+
protected handleParameter(subject: TagManagerSubject, parameter: string, parameterValue: ParameterValue): Promise<ParameterObserver>;
|
|
95
|
+
/**
|
|
96
|
+
* Updates the state of the {@link TagManager}'s {@link parameters} for all new nodes and tags given in
|
|
97
|
+
* {@link TagMapping}.
|
|
98
|
+
* @protected
|
|
99
|
+
*/
|
|
100
|
+
protected updateParametersWithNodeAndTagMapping(nodes: TransformNode[], tagMapping: TagMapping): void;
|
|
101
|
+
/**
|
|
102
|
+
* Clears the applied {@link ParameterBag} state of the node's metadata to ensure that observers trigger (once again).
|
|
103
|
+
* This is necessary e.g. after mapping tags when a nodeName subject shall override the parameterValue of a mapped
|
|
104
|
+
* tag.
|
|
105
|
+
* @protected
|
|
106
|
+
*/
|
|
107
|
+
protected clearAppliedNodeMetadataParameters(nodes: TransformNode[]): void;
|
|
108
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventBroadcaster } from '../classes/eventBroadcaster';
|
|
2
|
+
import { Scene as BabylonScene } from '@babylonjs/core/scene';
|
|
3
|
+
/**
|
|
4
|
+
* Keeps track of all texture loading/ready states and fires {@link Event.TEXTURE_LOADING_START} and
|
|
5
|
+
* {@link Event.TEXTURE_LOADING_END} events.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TextureLoadManager extends EventBroadcaster {
|
|
8
|
+
scene: BabylonScene;
|
|
9
|
+
private readonly _loadingTextures;
|
|
10
|
+
private _readyStatePollingIntervalMs;
|
|
11
|
+
private _readyStatePollingId;
|
|
12
|
+
private constructor();
|
|
13
|
+
static create(scene: BabylonScene): TextureLoadManager;
|
|
14
|
+
private startReadyStatePollingIfNeeded;
|
|
15
|
+
private endReadyStatePollingIfNeeded;
|
|
16
|
+
/**
|
|
17
|
+
* Checks the "ready state" of all textures inside the `this._loadingTextures` map, removes the ready ones and fires
|
|
18
|
+
* the {@link Event.TEXTURE_LOADING_END} event if no more textures are loading (i.e. "all ready").
|
|
19
|
+
*/
|
|
20
|
+
private checkLoadingTexturesState;
|
|
21
|
+
private onTextureAdded;
|
|
22
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { EventBroadcaster } from '../classes/eventBroadcaster';
|
|
2
|
+
import { Variant } from '../classes/variant';
|
|
3
|
+
import { VariantInstance } from '../classes/variantInstance';
|
|
4
|
+
/**
|
|
5
|
+
* There's usually no need to instantiate a {@link VariantInstanceManager} yourself as it is provided by each
|
|
6
|
+
* {@link Viewer} instance via its {@link Viewer.variantInstances}
|
|
7
|
+
*/
|
|
8
|
+
export declare class VariantInstanceManager extends EventBroadcaster {
|
|
9
|
+
viewer: Viewer;
|
|
10
|
+
protected rootVariant: Variant;
|
|
11
|
+
protected variantInstancePromises: Map<string, Promise<VariantInstance>>;
|
|
12
|
+
protected variantInstances: Map<string, VariantInstance>;
|
|
13
|
+
protected variantInstanceDefinitions: Map<string, VariantInstanceDefinition>;
|
|
14
|
+
protected parameters: ParameterBag;
|
|
15
|
+
protected queues: {
|
|
16
|
+
[name: string]: Promise<VariantInstance>[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Constructor.
|
|
20
|
+
*/
|
|
21
|
+
protected constructor(viewer: Viewer, rootVariant: Variant);
|
|
22
|
+
/**
|
|
23
|
+
* Creates a {@link VariantInstanceManager} based on given root Variant.
|
|
24
|
+
*/
|
|
25
|
+
static create(viewer: Viewer): Promise<VariantInstanceManager>;
|
|
26
|
+
/**
|
|
27
|
+
* Gets all instances.
|
|
28
|
+
*/
|
|
29
|
+
get all(): VariantInstance[];
|
|
30
|
+
/**
|
|
31
|
+
* Gets all instance definitions.
|
|
32
|
+
*/
|
|
33
|
+
get allDefinitions(): VariantInstanceDefinition[];
|
|
34
|
+
/**
|
|
35
|
+
* Gets all {@link VariantInstance}s with given {@link Variant}'s name.
|
|
36
|
+
*/
|
|
37
|
+
allWithVariantName(name: string): VariantInstance[];
|
|
38
|
+
/**
|
|
39
|
+
* Checks whether a {@link VariantInstance} is either registered or created.
|
|
40
|
+
*/
|
|
41
|
+
has(name: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Retrieves a {@link VariantInstance}.
|
|
44
|
+
* If the instance has been created, the created instance will be returned.
|
|
45
|
+
* If the instance is registered, the instance will be created and returned.
|
|
46
|
+
* if the instance has already been requested and is currently pending, the dedicated promise will be returned.
|
|
47
|
+
* If none of these apply, an Error is thrown.
|
|
48
|
+
*
|
|
49
|
+
* @emits {@link Event.VARIANT_INSTANCE_CREATED}
|
|
50
|
+
*/
|
|
51
|
+
get(name: string): Promise<VariantInstance>;
|
|
52
|
+
/**
|
|
53
|
+
* Creates and registers a unique {@link VariantInstance}.
|
|
54
|
+
*
|
|
55
|
+
* @emits {@link Event.VARIANT_INSTANCE_CREATED}
|
|
56
|
+
*/
|
|
57
|
+
create(dottedPath: DottedPathArgument, name?: string, parameters?: ParameterBag): Promise<VariantInstance>;
|
|
58
|
+
/**
|
|
59
|
+
* Registers a unique {@link VariantInstanceDefinition}.
|
|
60
|
+
*
|
|
61
|
+
* @emits {@link Event.VARIANT_INSTANCE_REGISTERED}
|
|
62
|
+
*/
|
|
63
|
+
register(instanceDefinition: VariantInstanceDefinition): VariantInstanceDefinition;
|
|
64
|
+
/**
|
|
65
|
+
* Commits the {@link ParameterBag} to all registered and created {@link VariantInstance}s.
|
|
66
|
+
*/
|
|
67
|
+
commitParameters(parameters?: ParameterBag, onlyVisible?: boolean): Promise<VariantInstanceManager>;
|
|
68
|
+
/**
|
|
69
|
+
* Show one {@link VariantInstance}. If `exclusive` is set to `true` it will hide all other
|
|
70
|
+
* instances handled by this {@link VariantInstanceManager}. If the function is called synchronously,
|
|
71
|
+
* the calls end up in a queue according to the FIFO principle (the last one wins).
|
|
72
|
+
*/
|
|
73
|
+
show(name: string, exclusive?: boolean): Promise<VariantInstance>;
|
|
74
|
+
/**
|
|
75
|
+
* Clones and registers a new {@link VariantInstance} with a new, unique name.
|
|
76
|
+
*
|
|
77
|
+
* @param tagMapping Object for renaming tags on the clone, whereas the "key" is the tag name of orignal variant
|
|
78
|
+
* instance and the "value" is the new tag name that should be created from it.\
|
|
79
|
+
* Check the docs of the tag managers
|
|
80
|
+
* [renaming](./../pages/documentation/Tag-Manager.html#uniqueness-of-node-and-tag-names)
|
|
81
|
+
* chapter for further details.
|
|
82
|
+
*
|
|
83
|
+
* @emits {@link Event.VARIANT_INSTANCE_CLONED}
|
|
84
|
+
*/
|
|
85
|
+
clone(name: string, newName: string, parameters?: ParameterBag, tagMapping?: TagMapping): Promise<VariantInstance>;
|
|
86
|
+
/**
|
|
87
|
+
* Destroys the instance by removing the {@link Variant} and de-registering the instance.
|
|
88
|
+
*
|
|
89
|
+
* @emits {@link Event.VARIANT_INSTANCE_DESTROYED}
|
|
90
|
+
*/
|
|
91
|
+
destroy(name: string): VariantInstanceManager;
|
|
92
|
+
/**
|
|
93
|
+
* Creates and registers a unique {@link VariantInstance} from `definition`.
|
|
94
|
+
*
|
|
95
|
+
* @emits {@link Event.VARIANT_INSTANCE_CREATED}
|
|
96
|
+
*/
|
|
97
|
+
protected createFromDefinition(definition: VariantInstanceDefinition): Promise<VariantInstance>;
|
|
98
|
+
/**
|
|
99
|
+
* Creates a unique instance name based on already registered instance names on the {@link VariantInstanceManager}.
|
|
100
|
+
* Appends an `_i` to the name where `i = 0` and increments as long as the name is not registered.
|
|
101
|
+
*/
|
|
102
|
+
protected ensureUniqueName(name: string): string;
|
|
103
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare class SpecStorage {
|
|
2
|
+
protected spec: StructureJson;
|
|
3
|
+
static instance: SpecStorage | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
*/
|
|
7
|
+
protected constructor(spec: StructureJson);
|
|
8
|
+
/**
|
|
9
|
+
* Creates {@link SpecStorage} from spec.
|
|
10
|
+
*/
|
|
11
|
+
static createFromSpec(structureJson: StructureJson): SpecStorage;
|
|
12
|
+
/**
|
|
13
|
+
* Gets the {@link SpecStorage} instance.
|
|
14
|
+
*/
|
|
15
|
+
static getInstance(): SpecStorage;
|
|
16
|
+
/**
|
|
17
|
+
* Gets the spec from the {@link SpecStorage}.
|
|
18
|
+
*/
|
|
19
|
+
static getSpec(): StructureJson;
|
|
20
|
+
/**
|
|
21
|
+
* Destroys the current instance to allow reinstantiating the SpecStorage.
|
|
22
|
+
*/
|
|
23
|
+
static destroy(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Gets spec from key.
|
|
26
|
+
*/
|
|
27
|
+
static get<T>(key?: string): T;
|
|
28
|
+
/**
|
|
29
|
+
* Sets value for spec for given key.
|
|
30
|
+
*/
|
|
31
|
+
static set<T>(key: string, value: T): typeof SpecStorage;
|
|
32
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { DottedPath } from '../classes/dottedPath';
|
|
2
|
+
import { HighlightLayer } from '@babylonjs/core/Layers/highlightLayer';
|
|
3
|
+
import { ShadowGenerator } from '@babylonjs/core/Lights/Shadows/shadowGenerator';
|
|
4
|
+
import { BaseTexture } from '@babylonjs/core/Materials/Textures/baseTexture';
|
|
5
|
+
import { Material } from '@babylonjs/core/Materials/material';
|
|
6
|
+
import { Color3 } from '@babylonjs/core/Maths/math.color';
|
|
7
|
+
import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';
|
|
8
|
+
import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
|
|
9
|
+
import { Observable } from '@babylonjs/core/Misc/observable';
|
|
10
|
+
import { Node } from '@babylonjs/core/node';
|
|
11
|
+
import { Scene } from '@babylonjs/core/scene';
|
|
12
|
+
declare const backgroundDomeName = "BackgroundDome_ViewerGenerated";
|
|
13
|
+
declare const envHelperMetadataName = "viewerEnvHelper";
|
|
14
|
+
/**
|
|
15
|
+
* @param node
|
|
16
|
+
* @return Node
|
|
17
|
+
*/
|
|
18
|
+
declare const getRootNode: (node: Node) => Node;
|
|
19
|
+
/**
|
|
20
|
+
* @param nodes
|
|
21
|
+
* @param predicate
|
|
22
|
+
* @return Map<DottedPath, T>
|
|
23
|
+
*/
|
|
24
|
+
declare const mapToDottedNodes: <T>(nodes: Node[], predicate?: ((node: Node) => boolean) | undefined) => Map<DottedPath, T>;
|
|
25
|
+
/**
|
|
26
|
+
* @param node
|
|
27
|
+
* @return DottedPath
|
|
28
|
+
*/
|
|
29
|
+
declare const getDottedPathForNode: (node: Node) => DottedPath;
|
|
30
|
+
/**
|
|
31
|
+
* @param node
|
|
32
|
+
* @param nodeNamingStrategy
|
|
33
|
+
* @param predicate
|
|
34
|
+
* @param deep
|
|
35
|
+
* @return TransformNode | null
|
|
36
|
+
*/
|
|
37
|
+
declare const cloneTransformNode: (node: TransformNode, nodeNamingStrategy: NodeNamingStrategy, predicate?: ((node: TransformNode) => boolean) | undefined, deep?: boolean) => TransformNode | null;
|
|
38
|
+
/**
|
|
39
|
+
* @param node
|
|
40
|
+
*/
|
|
41
|
+
declare const cloneNodeWithParents: (node: Node | null) => Node | null;
|
|
42
|
+
/**
|
|
43
|
+
* @param node
|
|
44
|
+
* @param deep
|
|
45
|
+
* @param prefix
|
|
46
|
+
* @return TransformNode
|
|
47
|
+
*/
|
|
48
|
+
declare const cloneTransformNodeMaterial: (node: TransformNode, prefix?: DottedPathArgument, deep?: boolean) => TransformNode;
|
|
49
|
+
/**
|
|
50
|
+
* @param node
|
|
51
|
+
* @param deep
|
|
52
|
+
* @param metadata
|
|
53
|
+
*/
|
|
54
|
+
declare const injectNodeMetadata: (node: Node, metadata: {}, deep?: boolean) => void;
|
|
55
|
+
/**
|
|
56
|
+
* @param node
|
|
57
|
+
* @param assertCallable
|
|
58
|
+
* @param callableParameters
|
|
59
|
+
* @param deep
|
|
60
|
+
*/
|
|
61
|
+
declare const assertTransformNode: (node: TransformNode, assertCallable: (node: TransformNode, ...args: any[]) => void, callableParameters?: any[], deep?: boolean) => void;
|
|
62
|
+
/**
|
|
63
|
+
* @param node
|
|
64
|
+
* @param parameter
|
|
65
|
+
*/
|
|
66
|
+
declare const assertMeshCapability: (node: TransformNode, parameter: string) => void;
|
|
67
|
+
/**
|
|
68
|
+
* @param node
|
|
69
|
+
* @param deep
|
|
70
|
+
*/
|
|
71
|
+
declare const activateTransformNode: (node: TransformNode, deep?: boolean) => void;
|
|
72
|
+
/**
|
|
73
|
+
* @param node
|
|
74
|
+
* @param deep
|
|
75
|
+
*/
|
|
76
|
+
declare const deactivateTransformNode: (node: TransformNode, deep?: boolean) => void;
|
|
77
|
+
/**
|
|
78
|
+
* @param node
|
|
79
|
+
*/
|
|
80
|
+
declare const enableNodeWithParents: (node: Node) => void;
|
|
81
|
+
/**
|
|
82
|
+
* @param node
|
|
83
|
+
*/
|
|
84
|
+
declare const disableNodeWithParents: (node: Node) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Applies a {@link TransformationDefinition} consecutively to ensure dependencies in positioning etc.
|
|
87
|
+
* @param node
|
|
88
|
+
* @param transformation
|
|
89
|
+
*/
|
|
90
|
+
declare const transformTransformNode: (node: TransformNode, transformation: TransformationDefinition) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Apply changes of environment (background texture, etc.) consecutively in order to avoid dependency related issues.
|
|
93
|
+
* @param scene
|
|
94
|
+
* @param envDef
|
|
95
|
+
*/
|
|
96
|
+
declare const changeEnvironment: (scene: Scene, envDef: EnvironmentDefinition) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Sets a material by a given material id as material property on the given node.
|
|
99
|
+
*
|
|
100
|
+
* If the material is not already available in the scene, the viewer tries to create a material based on a Combeenation
|
|
101
|
+
* [material asset](https://docs.combeenation.com/docs/howto-create-and-use-babylon-and-material-asset).
|
|
102
|
+
* This of course only works if the viewer is used inside a Combeenation configurator.
|
|
103
|
+
*
|
|
104
|
+
* Furthermore this function also defers the material creation if the node is not visible yet to improve network &
|
|
105
|
+
* viewer bootstrap performance as textures are automatically being lazy loaded only when they are actually visible in
|
|
106
|
+
* the scene.
|
|
107
|
+
*
|
|
108
|
+
* Finally the material will not be applied before all its textures have been loaded. In this way "flickering" effects
|
|
109
|
+
* will be avoided, since the material would be incomplete without its loaded textures.
|
|
110
|
+
*/
|
|
111
|
+
declare const setMaterial: (node: TransformNode, materialId: string, deep?: boolean, variant?: Variant) => void;
|
|
112
|
+
/**
|
|
113
|
+
* Gets the Material either from the given {@link Variant}, the given scene or tries to create it from an Combeenation
|
|
114
|
+
* material asset when inside a Combeenation configurator.
|
|
115
|
+
*/
|
|
116
|
+
declare const getOrCreateMaterial: (scene: Scene, materialId: string, variant?: Variant) => Material;
|
|
117
|
+
/**
|
|
118
|
+
* Waits until the materials textures are loaded and shaders are compiled.
|
|
119
|
+
* Then sets the material on the node if there is no newer "set material" request
|
|
120
|
+
*/
|
|
121
|
+
declare const applyMaterial: (material: Material, node: AbstractMesh) => Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* !!! Warning !!!
|
|
124
|
+
* This function is not public API. Whilst it can help solving certain problems, it only works reliably in well defined
|
|
125
|
+
* situations and can cause unwanted side effects under some conditions. Use carefully at your own risk!
|
|
126
|
+
*
|
|
127
|
+
* See https://combeenation.myjetbrains.com/youtrack/issue/CB-5906 for further details regarding this warning.
|
|
128
|
+
*
|
|
129
|
+
* Set material of an instanced meshes source mesh.
|
|
130
|
+
* Changes the material of all instanced meshes which have the same source mesh.
|
|
131
|
+
*
|
|
132
|
+
* @param node
|
|
133
|
+
* @param material
|
|
134
|
+
* @param deep
|
|
135
|
+
*
|
|
136
|
+
* @ignore
|
|
137
|
+
*/
|
|
138
|
+
declare const setSourceNodeMaterial: (node: TransformNode, material: Material, deep?: boolean) => void;
|
|
139
|
+
/**
|
|
140
|
+
* @param node
|
|
141
|
+
* @param color
|
|
142
|
+
* @param deep
|
|
143
|
+
*/
|
|
144
|
+
declare const setMaterialColor: (node: TransformNode, color: Color3, deep?: boolean) => void;
|
|
145
|
+
/**
|
|
146
|
+
* @param node
|
|
147
|
+
* @param texture
|
|
148
|
+
* @param deep
|
|
149
|
+
*/
|
|
150
|
+
declare const setMaterialTexture: (node: TransformNode, texture: Texture, deep?: boolean) => void;
|
|
151
|
+
/**
|
|
152
|
+
* @param node
|
|
153
|
+
* @param metallness
|
|
154
|
+
* @param deep
|
|
155
|
+
*/
|
|
156
|
+
declare const setMaterialMetallness: (node: TransformNode, metallness: number, deep?: boolean) => void;
|
|
157
|
+
/**
|
|
158
|
+
* @param node
|
|
159
|
+
* @param roughness
|
|
160
|
+
* @param deep
|
|
161
|
+
*/
|
|
162
|
+
declare const setMaterialRoughness: (node: TransformNode, roughness: number, deep?: boolean) => void;
|
|
163
|
+
/**
|
|
164
|
+
* @param node
|
|
165
|
+
* @param layer
|
|
166
|
+
* @param color
|
|
167
|
+
* @param deep
|
|
168
|
+
*/
|
|
169
|
+
declare const addToHighlightLayer: (layer: HighlightLayer, color: Color3, node: TransformNode, deep?: boolean) => void;
|
|
170
|
+
/**
|
|
171
|
+
* @param node
|
|
172
|
+
* @param layer
|
|
173
|
+
* @param deep
|
|
174
|
+
*/
|
|
175
|
+
declare const removeFromHighlightLayer: (layer: HighlightLayer, node: TransformNode, deep?: boolean) => void;
|
|
176
|
+
/**
|
|
177
|
+
* @param node
|
|
178
|
+
* @param receiveShadows
|
|
179
|
+
* @param deep
|
|
180
|
+
*/
|
|
181
|
+
declare const setReceiveShadows: (node: TransformNode, receiveShadows: boolean, deep?: boolean) => void;
|
|
182
|
+
/**
|
|
183
|
+
* @param node
|
|
184
|
+
* @param generator
|
|
185
|
+
* @param deep
|
|
186
|
+
*/
|
|
187
|
+
declare const addToShadowGenerator: (generator: ShadowGenerator, node: TransformNode, deep?: boolean) => void;
|
|
188
|
+
/**
|
|
189
|
+
* @param node
|
|
190
|
+
* @param generator
|
|
191
|
+
* @param deep
|
|
192
|
+
*/
|
|
193
|
+
declare const removeFromShadowGenerator: (generator: ShadowGenerator, node: TransformNode, deep?: boolean) => void;
|
|
194
|
+
/**
|
|
195
|
+
* https://forum.babylonjs.com/t/get-mesh-bounding-box-position-and-size-in-2d-screen-coordinates/1058/3
|
|
196
|
+
* @param mesh
|
|
197
|
+
* @param scene
|
|
198
|
+
* @param canvas
|
|
199
|
+
*/
|
|
200
|
+
declare const getClientRectFromMesh: (mesh: AbstractMesh, scene: Scene, canvas: HTMLCanvasElement) => ClientRect;
|
|
201
|
+
declare type BaseTextureWithOnLoadObservable = BaseTexture & {
|
|
202
|
+
onLoadObservable: Observable<BaseTexture>;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* This type guard checks whether the given `BaseTextures` is any of its subtypes which comes with an
|
|
206
|
+
* `onLoadObservable`.
|
|
207
|
+
*
|
|
208
|
+
* !!! Timing of when this function is called is important !!!
|
|
209
|
+
* See the following for more details: https://forum.babylonjs.com/t/basetexture-whenallready-returns-too-early/34501/6
|
|
210
|
+
*/
|
|
211
|
+
declare const isTextureWithOnLoadObservable: (texture: BaseTexture) => texture is BaseTextureWithOnLoadObservable;
|
|
212
|
+
/**
|
|
213
|
+
* @param objects
|
|
214
|
+
* @param tagMapping
|
|
215
|
+
*/
|
|
216
|
+
declare const mapTags: (objects: object[], tagMapping: TagMapping) => string[];
|
|
217
|
+
/**
|
|
218
|
+
* Gets an array of ids for nodeIds that exist in both TransformNode arrays.
|
|
219
|
+
* @param nodes1
|
|
220
|
+
* @param nodes2
|
|
221
|
+
* @param predicate
|
|
222
|
+
*/
|
|
223
|
+
declare const intersectingNodeNames: (nodes1: Node[], nodes2: Node[], predicate?: ((node: Node) => boolean) | undefined) => string[];
|
|
224
|
+
/**
|
|
225
|
+
* Gets an array of ids for duplicate nodeIds in given node array.
|
|
226
|
+
* @param nodes
|
|
227
|
+
* @param predicate
|
|
228
|
+
*/
|
|
229
|
+
declare const duplicateNodeNames: (nodes: Node[], predicate?: ((node: Node) => boolean) | undefined) => string[];
|
|
230
|
+
/**
|
|
231
|
+
* Reports duplicate nodeIds.
|
|
232
|
+
* @param nodeNames
|
|
233
|
+
*/
|
|
234
|
+
declare const reportDuplicateNodeNames: (nodeNames: string[]) => void;
|
|
235
|
+
export { getRootNode, isTextureWithOnLoadObservable, mapToDottedNodes, getDottedPathForNode, cloneTransformNode, cloneNodeWithParents, cloneTransformNodeMaterial, getOrCreateMaterial, applyMaterial, injectNodeMetadata, assertTransformNode, assertMeshCapability, activateTransformNode, deactivateTransformNode, enableNodeWithParents, disableNodeWithParents, transformTransformNode, setMaterial, setSourceNodeMaterial, setMaterialColor, setMaterialTexture, setMaterialMetallness, setMaterialRoughness, addToHighlightLayer, removeFromHighlightLayer, setReceiveShadows, addToShadowGenerator, removeFromShadowGenerator, getClientRectFromMesh, changeEnvironment, backgroundDomeName, envHelperMetadataName, mapTags, intersectingNodeNames, duplicateNodeNames, reportDuplicateNodeNames, };
|