@itwin/core-backend 3.5.0-dev.18 → 3.5.0-dev.20
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/CHANGELOG.md +8 -1
- package/lib/cjs/AliCloudStorageService.d.ts +23 -23
- package/lib/cjs/AliCloudStorageService.js +71 -71
- package/lib/cjs/AliCloudStorageService.js.map +1 -1
- package/lib/cjs/BackendHubAccess.d.ts +224 -224
- package/lib/cjs/BackendHubAccess.js +41 -41
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.d.ts +91 -91
- package/lib/cjs/BackendLoggerCategory.js +99 -99
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.d.ts +21 -21
- package/lib/cjs/BisCoreSchema.js +60 -60
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BriefcaseManager.d.ts +165 -165
- package/lib/cjs/BriefcaseManager.js +405 -405
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.d.ts +153 -153
- package/lib/cjs/Category.js +243 -243
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
- package/lib/cjs/ChangeSummaryManager.js +445 -445
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts +99 -99
- package/lib/cjs/ChangedElementsDb.js +165 -165
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangedElementsManager.d.ts +39 -39
- package/lib/cjs/ChangedElementsManager.js +88 -88
- package/lib/cjs/ChangedElementsManager.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts +120 -120
- package/lib/cjs/CheckpointManager.js +343 -343
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts +72 -71
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +243 -215
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +350 -349
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +152 -151
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CloudStorageBackend.d.ts +58 -58
- package/lib/cjs/CloudStorageBackend.js +173 -173
- package/lib/cjs/CloudStorageBackend.js.map +1 -1
- package/lib/cjs/CodeService.d.ts +396 -396
- package/lib/cjs/CodeService.js +63 -63
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.d.ts +50 -50
- package/lib/cjs/CodeSpecs.js +112 -112
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.d.ts +11 -11
- package/lib/cjs/ConcurrentQuery.js +30 -30
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.d.ts +32 -32
- package/lib/cjs/CustomViewState3dCreator.js +113 -113
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.d.ts +71 -71
- package/lib/cjs/DevTools.js +154 -154
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +106 -106
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +256 -256
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +191 -191
- package/lib/cjs/ECDb.js +350 -350
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
- package/lib/cjs/ECSchemaXmlContext.js +41 -41
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +466 -466
- package/lib/cjs/ECSqlStatement.js +791 -791
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +1102 -1109
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +1416 -1420
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +158 -156
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +186 -178
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.d.ts +9 -9
- package/lib/cjs/ElementGraphics.js +41 -41
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.d.ts +162 -162
- package/lib/cjs/ElementTreeWalker.js +409 -409
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.d.ts +106 -76
- package/lib/cjs/Entity.d.ts.map +1 -1
- package/lib/cjs/Entity.js +134 -82
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.d.ts +50 -0
- package/lib/cjs/EntityReferences.d.ts.map +1 -0
- package/lib/cjs/EntityReferences.js +96 -0
- package/lib/cjs/EntityReferences.js.map +1 -0
- package/lib/cjs/ExportGraphics.d.ts +317 -317
- package/lib/cjs/ExportGraphics.js +208 -208
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.d.ts +96 -94
- package/lib/cjs/ExternalSource.d.ts.map +1 -1
- package/lib/cjs/ExternalSource.js +131 -125
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.d.ts +19 -19
- package/lib/cjs/GeoCoordConfig.js +82 -82
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeometrySummary.d.ts +4 -4
- package/lib/cjs/GeometrySummary.js +380 -380
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/HubMock.d.ts +93 -93
- package/lib/cjs/HubMock.js +190 -190
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelCloneContext.d.ts +8 -85
- package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelCloneContext.js +15 -150
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +1167 -1164
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +2332 -2324
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.d.ts +90 -0
- package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -0
- package/lib/cjs/IModelElementCloneContext.js +160 -0
- package/lib/cjs/IModelElementCloneContext.js.map +1 -0
- package/lib/cjs/IModelHost.d.ts +369 -361
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +492 -489
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.d.ts +62 -62
- package/lib/cjs/IModelJsFs.js +140 -140
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts +98 -98
- package/lib/cjs/IpcHost.js +234 -234
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.d.ts +311 -311
- package/lib/cjs/LineStyle.js +295 -295
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.d.ts +162 -162
- package/lib/cjs/LocalHub.js +587 -587
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
- package/lib/cjs/LocalhostIpcHost.js +81 -81
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/Material.d.ts +103 -103
- package/lib/cjs/Material.js +147 -147
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +388 -386
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +479 -471
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeAppStorage.d.ts +51 -51
- package/lib/cjs/NativeAppStorage.js +202 -202
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.d.ts +52 -52
- package/lib/cjs/NativeHost.js +168 -168
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.d.ts +156 -156
- package/lib/cjs/NavigationRelationship.js +225 -225
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.d.ts +51 -51
- package/lib/cjs/PromiseMemoizer.js +101 -101
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.d.ts +132 -132
- package/lib/cjs/PropertyStore.js +11 -11
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +416 -400
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +494 -465
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.d.ts +28 -28
- package/lib/cjs/RpcBackend.js +126 -126
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts +219 -219
- package/lib/cjs/SQLiteDb.js +214 -214
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.d.ts +55 -55
- package/lib/cjs/Schema.js +83 -83
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/ServerBasedLocks.d.ts +57 -57
- package/lib/cjs/ServerBasedLocks.js +168 -168
- package/lib/cjs/ServerBasedLocks.js.map +1 -1
- package/lib/cjs/SqliteStatement.d.ts +360 -283
- package/lib/cjs/SqliteStatement.d.ts.map +1 -1
- package/lib/cjs/SqliteStatement.js +586 -448
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/Texture.d.ts +58 -58
- package/lib/cjs/Texture.js +82 -82
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TileStorage.d.ts +18 -18
- package/lib/cjs/TileStorage.js +90 -90
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +202 -202
- package/lib/cjs/TxnManager.js +356 -356
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +439 -435
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +646 -635
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.d.ts +13 -13
- package/lib/cjs/ViewStateHydrator.js +103 -103
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
- package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
- package/lib/cjs/core-backend.d.ts +184 -182
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +204 -202
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
- package/lib/cjs/domains/FunctionalElements.js +145 -145
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
- package/lib/cjs/domains/FunctionalSchema.js +40 -40
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.d.ts +177 -177
- package/lib/cjs/domains/GenericElements.js +263 -263
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.d.ts +10 -10
- package/lib/cjs/domains/GenericSchema.js +28 -28
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +45 -45
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +262 -262
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +204 -204
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +168 -168
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +43 -43
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
- package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
- package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.d.ts +186 -186
- package/lib/cjs/workspace/Settings.js +155 -155
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
- package/lib/cjs/workspace/SettingsSchemas.js +191 -191
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.d.ts +414 -414
- package/lib/cjs/workspace/Workspace.js +543 -543
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/package.json +14 -13
package/lib/cjs/Material.d.ts
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Elements
|
|
3
|
-
*/
|
|
4
|
-
import { Id64String } from "@itwin/core-bentley";
|
|
5
|
-
import { Code, CodeScopeProps, RenderMaterialProps, TextureMapProps } from "@itwin/core-common";
|
|
6
|
-
import { DefinitionElement } from "./Element";
|
|
7
|
-
import { IModelDb } from "./IModelDb";
|
|
8
|
-
/** A PhysicalMaterial defines the matter that makes up physical elements.
|
|
9
|
-
* @note See [[RenderMaterialElement]] for the DefinitionElement used to define rendering characteristics.
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export declare abstract class PhysicalMaterial extends DefinitionElement {
|
|
13
|
-
/** @internal */
|
|
14
|
-
static get className(): string;
|
|
15
|
-
/** Create a Code for a PhysicalMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
16
|
-
* @param iModel The IModelDb
|
|
17
|
-
* @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.
|
|
18
|
-
* @param name The name (codeValue) of the PhysicalMaterial
|
|
19
|
-
*/
|
|
20
|
-
static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code;
|
|
21
|
-
/** Create a PhysicalMaterial
|
|
22
|
-
* @param iModelDb The IModelDb
|
|
23
|
-
* @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.
|
|
24
|
-
* @param name The name (codeValue) of the PhysicalMaterial
|
|
25
|
-
* @returns The newly constructed PhysicalMaterial
|
|
26
|
-
* @throws [[IModelError]] if there is a problem creating the PhysicalMaterial
|
|
27
|
-
*/
|
|
28
|
-
static create<T extends PhysicalMaterial>(iModelDb: IModelDb, definitionModelId: CodeScopeProps, name: string): T;
|
|
29
|
-
}
|
|
30
|
-
/** Defines a rendering material.
|
|
31
|
-
* @note See [[PhysicalMaterial]] for the DefinitionElement used to define the matter that makes up physical elements.
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export declare class RenderMaterialElement extends DefinitionElement {
|
|
35
|
-
/** @internal */
|
|
36
|
-
static get className(): string;
|
|
37
|
-
/** The name of a palette that can be used to categorize multiple materials. */
|
|
38
|
-
paletteName: string;
|
|
39
|
-
/** An optional description of the material. */
|
|
40
|
-
description?: string;
|
|
41
|
-
/** @internal */
|
|
42
|
-
constructor(props: RenderMaterialProps, iModel: IModelDb);
|
|
43
|
-
/** @internal */
|
|
44
|
-
toJSON(): RenderMaterialProps;
|
|
45
|
-
/** Create a Code for a RenderMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
46
|
-
* @param iModel The IModelDb
|
|
47
|
-
* @param scopeModelId The Id of the DefinitionModel that contains the RenderMaterial and provides the scope for its name.
|
|
48
|
-
* @param name The RenderMaterial name
|
|
49
|
-
*/
|
|
50
|
-
static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, name: string): Code;
|
|
51
|
-
/**
|
|
52
|
-
* Create a RenderMaterial with given parameters.
|
|
53
|
-
* @param iModelDb The iModel
|
|
54
|
-
* @param definitionModelId The [[DefinitionModel]]
|
|
55
|
-
* @param materialName The name/CodeValue of the RenderMaterial
|
|
56
|
-
* @param params Parameters object which describes how to construct the RenderMaterial
|
|
57
|
-
* @returns The newly constructed RenderMaterial element.
|
|
58
|
-
* @throws [[IModelError]] if unable to create the element.
|
|
59
|
-
*/
|
|
60
|
-
static create(iModelDb: IModelDb, definitionModelId: Id64String, materialName: string, params: RenderMaterialElement.Params): RenderMaterialElement;
|
|
61
|
-
/**
|
|
62
|
-
* Insert a new RenderMaterial into a model.
|
|
63
|
-
* @param iModelDb Insert into this iModel
|
|
64
|
-
* @param definitionModelId Insert the new Texture into this DefinitionModel
|
|
65
|
-
* @param materialName The name/CodeValue of the RenderMaterial
|
|
66
|
-
* @param params Parameters object which describes how to construct the RenderMaterial
|
|
67
|
-
* @returns The Id of the newly inserted RenderMaterial element.
|
|
68
|
-
* @throws [[IModelError]] if unable to insert the element.
|
|
69
|
-
*/
|
|
70
|
-
static insert(iModelDb: IModelDb, definitionModelId: Id64String, materialName: string, params: RenderMaterialElement.Params): Id64String;
|
|
71
|
-
}
|
|
72
|
-
/** @public
|
|
73
|
-
* @note color, specularColor and reflectColor are stored as [R,G,B] where each value is between 0 and 1
|
|
74
|
-
*/
|
|
75
|
-
export declare namespace RenderMaterialElement {
|
|
76
|
-
/** Parameters used to construct a [[RenderMaterial]]. */
|
|
77
|
-
class Params {
|
|
78
|
-
/** The palette name which categorizes this RenderMaterial */
|
|
79
|
-
paletteName: string;
|
|
80
|
-
/** The optional description for this RenderMaterial */
|
|
81
|
-
description?: string;
|
|
82
|
-
/** If defined, use this color for surface fill or diffuse illumination; if undefined, defaults to black */
|
|
83
|
-
color?: number[];
|
|
84
|
-
/** If defined, use this color for surface specular illumination; if undefined, defaults to black */
|
|
85
|
-
specularColor?: number[];
|
|
86
|
-
/** If defined, apply this specular exponent(surface shininess); range is 0 to 128; if undefined, defaults to 15.0 * 0.9 */
|
|
87
|
-
finish?: number;
|
|
88
|
-
/** If defined, apply this surface transparency; if undefined, defaults to 0.0 */
|
|
89
|
-
transmit?: number;
|
|
90
|
-
/** If defined, apply this surface diffuse reflectivity; if undefined, defaults to 0.6 */
|
|
91
|
-
diffuse?: number;
|
|
92
|
-
/** If defined, apply this surface specular reflectivity; if undefined, defaults to 0.0. NOTE: The actual JSON allows a HasSpecular property to be true and the specular value itself undefined, in which case the value 0.4 would be used. This API does not allow this case. */
|
|
93
|
-
specular?: number;
|
|
94
|
-
/** If defined, apply this surface environmental reflectivity; stored as fraction of specular in V8 material settings; if undefined, defaults to 0.0 */
|
|
95
|
-
reflect?: number;
|
|
96
|
-
/** If defined, apply this surface reflectance color; if undefined, defaults to whatever the specularColor is */
|
|
97
|
-
reflectColor?: number[];
|
|
98
|
-
/** If defined, specifies the pattern mapping. */
|
|
99
|
-
patternMap?: TextureMapProps;
|
|
100
|
-
/** Construct a new RenderMaterial.Params object with the specified paletteName. Alter the public members on that object to specify settings. */
|
|
101
|
-
constructor(paletteName: string);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Elements
|
|
3
|
+
*/
|
|
4
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
5
|
+
import { Code, CodeScopeProps, RenderMaterialProps, TextureMapProps } from "@itwin/core-common";
|
|
6
|
+
import { DefinitionElement } from "./Element";
|
|
7
|
+
import { IModelDb } from "./IModelDb";
|
|
8
|
+
/** A PhysicalMaterial defines the matter that makes up physical elements.
|
|
9
|
+
* @note See [[RenderMaterialElement]] for the DefinitionElement used to define rendering characteristics.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class PhysicalMaterial extends DefinitionElement {
|
|
13
|
+
/** @internal */
|
|
14
|
+
static get className(): string;
|
|
15
|
+
/** Create a Code for a PhysicalMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
16
|
+
* @param iModel The IModelDb
|
|
17
|
+
* @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.
|
|
18
|
+
* @param name The name (codeValue) of the PhysicalMaterial
|
|
19
|
+
*/
|
|
20
|
+
static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code;
|
|
21
|
+
/** Create a PhysicalMaterial
|
|
22
|
+
* @param iModelDb The IModelDb
|
|
23
|
+
* @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.
|
|
24
|
+
* @param name The name (codeValue) of the PhysicalMaterial
|
|
25
|
+
* @returns The newly constructed PhysicalMaterial
|
|
26
|
+
* @throws [[IModelError]] if there is a problem creating the PhysicalMaterial
|
|
27
|
+
*/
|
|
28
|
+
static create<T extends PhysicalMaterial>(iModelDb: IModelDb, definitionModelId: CodeScopeProps, name: string): T;
|
|
29
|
+
}
|
|
30
|
+
/** Defines a rendering material.
|
|
31
|
+
* @note See [[PhysicalMaterial]] for the DefinitionElement used to define the matter that makes up physical elements.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare class RenderMaterialElement extends DefinitionElement {
|
|
35
|
+
/** @internal */
|
|
36
|
+
static get className(): string;
|
|
37
|
+
/** The name of a palette that can be used to categorize multiple materials. */
|
|
38
|
+
paletteName: string;
|
|
39
|
+
/** An optional description of the material. */
|
|
40
|
+
description?: string;
|
|
41
|
+
/** @internal */
|
|
42
|
+
constructor(props: RenderMaterialProps, iModel: IModelDb);
|
|
43
|
+
/** @internal */
|
|
44
|
+
toJSON(): RenderMaterialProps;
|
|
45
|
+
/** Create a Code for a RenderMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
46
|
+
* @param iModel The IModelDb
|
|
47
|
+
* @param scopeModelId The Id of the DefinitionModel that contains the RenderMaterial and provides the scope for its name.
|
|
48
|
+
* @param name The RenderMaterial name
|
|
49
|
+
*/
|
|
50
|
+
static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, name: string): Code;
|
|
51
|
+
/**
|
|
52
|
+
* Create a RenderMaterial with given parameters.
|
|
53
|
+
* @param iModelDb The iModel
|
|
54
|
+
* @param definitionModelId The [[DefinitionModel]]
|
|
55
|
+
* @param materialName The name/CodeValue of the RenderMaterial
|
|
56
|
+
* @param params Parameters object which describes how to construct the RenderMaterial
|
|
57
|
+
* @returns The newly constructed RenderMaterial element.
|
|
58
|
+
* @throws [[IModelError]] if unable to create the element.
|
|
59
|
+
*/
|
|
60
|
+
static create(iModelDb: IModelDb, definitionModelId: Id64String, materialName: string, params: RenderMaterialElement.Params): RenderMaterialElement;
|
|
61
|
+
/**
|
|
62
|
+
* Insert a new RenderMaterial into a model.
|
|
63
|
+
* @param iModelDb Insert into this iModel
|
|
64
|
+
* @param definitionModelId Insert the new Texture into this DefinitionModel
|
|
65
|
+
* @param materialName The name/CodeValue of the RenderMaterial
|
|
66
|
+
* @param params Parameters object which describes how to construct the RenderMaterial
|
|
67
|
+
* @returns The Id of the newly inserted RenderMaterial element.
|
|
68
|
+
* @throws [[IModelError]] if unable to insert the element.
|
|
69
|
+
*/
|
|
70
|
+
static insert(iModelDb: IModelDb, definitionModelId: Id64String, materialName: string, params: RenderMaterialElement.Params): Id64String;
|
|
71
|
+
}
|
|
72
|
+
/** @public
|
|
73
|
+
* @note color, specularColor and reflectColor are stored as [R,G,B] where each value is between 0 and 1
|
|
74
|
+
*/
|
|
75
|
+
export declare namespace RenderMaterialElement {
|
|
76
|
+
/** Parameters used to construct a [[RenderMaterial]]. */
|
|
77
|
+
class Params {
|
|
78
|
+
/** The palette name which categorizes this RenderMaterial */
|
|
79
|
+
paletteName: string;
|
|
80
|
+
/** The optional description for this RenderMaterial */
|
|
81
|
+
description?: string;
|
|
82
|
+
/** If defined, use this color for surface fill or diffuse illumination; if undefined, defaults to black */
|
|
83
|
+
color?: number[];
|
|
84
|
+
/** If defined, use this color for surface specular illumination; if undefined, defaults to black */
|
|
85
|
+
specularColor?: number[];
|
|
86
|
+
/** If defined, apply this specular exponent(surface shininess); range is 0 to 128; if undefined, defaults to 15.0 * 0.9 */
|
|
87
|
+
finish?: number;
|
|
88
|
+
/** If defined, apply this surface transparency; if undefined, defaults to 0.0 */
|
|
89
|
+
transmit?: number;
|
|
90
|
+
/** If defined, apply this surface diffuse reflectivity; if undefined, defaults to 0.6 */
|
|
91
|
+
diffuse?: number;
|
|
92
|
+
/** If defined, apply this surface specular reflectivity; if undefined, defaults to 0.0. NOTE: The actual JSON allows a HasSpecular property to be true and the specular value itself undefined, in which case the value 0.4 would be used. This API does not allow this case. */
|
|
93
|
+
specular?: number;
|
|
94
|
+
/** If defined, apply this surface environmental reflectivity; stored as fraction of specular in V8 material settings; if undefined, defaults to 0.0 */
|
|
95
|
+
reflect?: number;
|
|
96
|
+
/** If defined, apply this surface reflectance color; if undefined, defaults to whatever the specularColor is */
|
|
97
|
+
reflectColor?: number[];
|
|
98
|
+
/** If defined, specifies the pattern mapping. */
|
|
99
|
+
patternMap?: TextureMapProps;
|
|
100
|
+
/** Construct a new RenderMaterial.Params object with the specified paletteName. Alter the public members on that object to specify settings. */
|
|
101
|
+
constructor(paletteName: string);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
104
|
//# sourceMappingURL=Material.d.ts.map
|
package/lib/cjs/Material.js
CHANGED
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Elements
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.RenderMaterialElement = exports.PhysicalMaterial = void 0;
|
|
11
|
-
const core_common_1 = require("@itwin/core-common");
|
|
12
|
-
const Element_1 = require("./Element");
|
|
13
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
14
|
-
/** A PhysicalMaterial defines the matter that makes up physical elements.
|
|
15
|
-
* @note See [[RenderMaterialElement]] for the DefinitionElement used to define rendering characteristics.
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
class PhysicalMaterial extends Element_1.DefinitionElement {
|
|
19
|
-
/** @internal */
|
|
20
|
-
static get className() { return "PhysicalMaterial"; }
|
|
21
|
-
/** Create a Code for a PhysicalMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
22
|
-
* @param iModel The IModelDb
|
|
23
|
-
* @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.
|
|
24
|
-
* @param name The name (codeValue) of the PhysicalMaterial
|
|
25
|
-
*/
|
|
26
|
-
static createCode(iModel, definitionModelId, name) {
|
|
27
|
-
const codeSpec = iModel.codeSpecs.getByName(core_common_1.BisCodeSpec.physicalMaterial);
|
|
28
|
-
return new core_common_1.Code({ spec: codeSpec.id, scope: definitionModelId, value: name });
|
|
29
|
-
}
|
|
30
|
-
/** Create a PhysicalMaterial
|
|
31
|
-
* @param iModelDb The IModelDb
|
|
32
|
-
* @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.
|
|
33
|
-
* @param name The name (codeValue) of the PhysicalMaterial
|
|
34
|
-
* @returns The newly constructed PhysicalMaterial
|
|
35
|
-
* @throws [[IModelError]] if there is a problem creating the PhysicalMaterial
|
|
36
|
-
*/
|
|
37
|
-
static create(iModelDb, definitionModelId, name) {
|
|
38
|
-
const elementProps = {
|
|
39
|
-
classFullName: this.classFullName,
|
|
40
|
-
model: definitionModelId,
|
|
41
|
-
code: this.createCode(iModelDb, definitionModelId, name),
|
|
42
|
-
};
|
|
43
|
-
return iModelDb.elements.createElement(elementProps);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.PhysicalMaterial = PhysicalMaterial;
|
|
47
|
-
/** Defines a rendering material.
|
|
48
|
-
* @note See [[PhysicalMaterial]] for the DefinitionElement used to define the matter that makes up physical elements.
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
class RenderMaterialElement extends Element_1.DefinitionElement {
|
|
52
|
-
/** @internal */
|
|
53
|
-
constructor(props, iModel) {
|
|
54
|
-
super(props, iModel);
|
|
55
|
-
this.paletteName = props.paletteName;
|
|
56
|
-
this.description = props.description;
|
|
57
|
-
}
|
|
58
|
-
/** @internal */
|
|
59
|
-
static get className() { return "RenderMaterial"; }
|
|
60
|
-
/** @internal */
|
|
61
|
-
toJSON() {
|
|
62
|
-
const val = super.toJSON();
|
|
63
|
-
val.paletteName = this.paletteName;
|
|
64
|
-
val.description = this.description;
|
|
65
|
-
return val;
|
|
66
|
-
}
|
|
67
|
-
/** Create a Code for a RenderMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
68
|
-
* @param iModel The IModelDb
|
|
69
|
-
* @param scopeModelId The Id of the DefinitionModel that contains the RenderMaterial and provides the scope for its name.
|
|
70
|
-
* @param name The RenderMaterial name
|
|
71
|
-
*/
|
|
72
|
-
static createCode(iModel, scopeModelId, name) {
|
|
73
|
-
const codeSpec = iModel.codeSpecs.getByName(core_common_1.BisCodeSpec.texture);
|
|
74
|
-
return 0 === name.length ? core_common_1.Code.createEmpty() : new core_common_1.Code({ spec: codeSpec.id, scope: scopeModelId, value: name });
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Create a RenderMaterial with given parameters.
|
|
78
|
-
* @param iModelDb The iModel
|
|
79
|
-
* @param definitionModelId The [[DefinitionModel]]
|
|
80
|
-
* @param materialName The name/CodeValue of the RenderMaterial
|
|
81
|
-
* @param params Parameters object which describes how to construct the RenderMaterial
|
|
82
|
-
* @returns The newly constructed RenderMaterial element.
|
|
83
|
-
* @throws [[IModelError]] if unable to create the element.
|
|
84
|
-
*/
|
|
85
|
-
static create(iModelDb, definitionModelId, materialName, params) {
|
|
86
|
-
const map = undefined !== params.patternMap ? { Pattern: params.patternMap } : undefined;
|
|
87
|
-
const renderMaterialProps = {
|
|
88
|
-
classFullName: this.classFullName,
|
|
89
|
-
code: this.createCode(iModelDb, definitionModelId, materialName),
|
|
90
|
-
paletteName: params.paletteName,
|
|
91
|
-
description: params.description,
|
|
92
|
-
jsonProperties: {
|
|
93
|
-
materialAssets: {
|
|
94
|
-
renderMaterial: {
|
|
95
|
-
HasBaseColor: params.color !== undefined,
|
|
96
|
-
color: params.color,
|
|
97
|
-
HasSpecularColor: params.specularColor !== undefined,
|
|
98
|
-
specular_color: params.specularColor,
|
|
99
|
-
HasFinish: params.finish !== undefined,
|
|
100
|
-
finish: params.finish,
|
|
101
|
-
HasTransmit: params.transmit !== undefined,
|
|
102
|
-
transmit: params.transmit,
|
|
103
|
-
HasDiffuse: params.diffuse !== undefined,
|
|
104
|
-
diffuse: params.diffuse,
|
|
105
|
-
HasSpecular: params.specular !== undefined,
|
|
106
|
-
specular: params.specular,
|
|
107
|
-
HasReflect: params.reflect !== undefined,
|
|
108
|
-
reflect: params.reflect,
|
|
109
|
-
HasReflectColor: params.reflectColor !== undefined,
|
|
110
|
-
reflect_color: params.reflectColor,
|
|
111
|
-
Map: map,
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
model: definitionModelId,
|
|
116
|
-
isPrivate: false,
|
|
117
|
-
};
|
|
118
|
-
return new RenderMaterialElement(renderMaterialProps, iModelDb);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Insert a new RenderMaterial into a model.
|
|
122
|
-
* @param iModelDb Insert into this iModel
|
|
123
|
-
* @param definitionModelId Insert the new Texture into this DefinitionModel
|
|
124
|
-
* @param materialName The name/CodeValue of the RenderMaterial
|
|
125
|
-
* @param params Parameters object which describes how to construct the RenderMaterial
|
|
126
|
-
* @returns The Id of the newly inserted RenderMaterial element.
|
|
127
|
-
* @throws [[IModelError]] if unable to insert the element.
|
|
128
|
-
*/
|
|
129
|
-
static insert(iModelDb, definitionModelId, materialName, params) {
|
|
130
|
-
const renderMaterial = this.create(iModelDb, definitionModelId, materialName, params);
|
|
131
|
-
return iModelDb.elements.insertElement(renderMaterial.toJSON());
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
exports.RenderMaterialElement = RenderMaterialElement;
|
|
135
|
-
/** @public
|
|
136
|
-
* @note color, specularColor and reflectColor are stored as [R,G,B] where each value is between 0 and 1
|
|
137
|
-
*/
|
|
138
|
-
(function (RenderMaterialElement) {
|
|
139
|
-
/** Parameters used to construct a [[RenderMaterial]]. */
|
|
140
|
-
class Params {
|
|
141
|
-
/** Construct a new RenderMaterial.Params object with the specified paletteName. Alter the public members on that object to specify settings. */
|
|
142
|
-
constructor(paletteName) {
|
|
143
|
-
this.paletteName = paletteName;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
RenderMaterialElement.Params = Params;
|
|
147
|
-
})(RenderMaterialElement = exports.RenderMaterialElement || (exports.RenderMaterialElement = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Elements
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.RenderMaterialElement = exports.PhysicalMaterial = void 0;
|
|
11
|
+
const core_common_1 = require("@itwin/core-common");
|
|
12
|
+
const Element_1 = require("./Element");
|
|
13
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
14
|
+
/** A PhysicalMaterial defines the matter that makes up physical elements.
|
|
15
|
+
* @note See [[RenderMaterialElement]] for the DefinitionElement used to define rendering characteristics.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
class PhysicalMaterial extends Element_1.DefinitionElement {
|
|
19
|
+
/** @internal */
|
|
20
|
+
static get className() { return "PhysicalMaterial"; }
|
|
21
|
+
/** Create a Code for a PhysicalMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
22
|
+
* @param iModel The IModelDb
|
|
23
|
+
* @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.
|
|
24
|
+
* @param name The name (codeValue) of the PhysicalMaterial
|
|
25
|
+
*/
|
|
26
|
+
static createCode(iModel, definitionModelId, name) {
|
|
27
|
+
const codeSpec = iModel.codeSpecs.getByName(core_common_1.BisCodeSpec.physicalMaterial);
|
|
28
|
+
return new core_common_1.Code({ spec: codeSpec.id, scope: definitionModelId, value: name });
|
|
29
|
+
}
|
|
30
|
+
/** Create a PhysicalMaterial
|
|
31
|
+
* @param iModelDb The IModelDb
|
|
32
|
+
* @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.
|
|
33
|
+
* @param name The name (codeValue) of the PhysicalMaterial
|
|
34
|
+
* @returns The newly constructed PhysicalMaterial
|
|
35
|
+
* @throws [[IModelError]] if there is a problem creating the PhysicalMaterial
|
|
36
|
+
*/
|
|
37
|
+
static create(iModelDb, definitionModelId, name) {
|
|
38
|
+
const elementProps = {
|
|
39
|
+
classFullName: this.classFullName,
|
|
40
|
+
model: definitionModelId,
|
|
41
|
+
code: this.createCode(iModelDb, definitionModelId, name),
|
|
42
|
+
};
|
|
43
|
+
return iModelDb.elements.createElement(elementProps);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.PhysicalMaterial = PhysicalMaterial;
|
|
47
|
+
/** Defines a rendering material.
|
|
48
|
+
* @note See [[PhysicalMaterial]] for the DefinitionElement used to define the matter that makes up physical elements.
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
class RenderMaterialElement extends Element_1.DefinitionElement {
|
|
52
|
+
/** @internal */
|
|
53
|
+
constructor(props, iModel) {
|
|
54
|
+
super(props, iModel);
|
|
55
|
+
this.paletteName = props.paletteName;
|
|
56
|
+
this.description = props.description;
|
|
57
|
+
}
|
|
58
|
+
/** @internal */
|
|
59
|
+
static get className() { return "RenderMaterial"; }
|
|
60
|
+
/** @internal */
|
|
61
|
+
toJSON() {
|
|
62
|
+
const val = super.toJSON();
|
|
63
|
+
val.paletteName = this.paletteName;
|
|
64
|
+
val.description = this.description;
|
|
65
|
+
return val;
|
|
66
|
+
}
|
|
67
|
+
/** Create a Code for a RenderMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.
|
|
68
|
+
* @param iModel The IModelDb
|
|
69
|
+
* @param scopeModelId The Id of the DefinitionModel that contains the RenderMaterial and provides the scope for its name.
|
|
70
|
+
* @param name The RenderMaterial name
|
|
71
|
+
*/
|
|
72
|
+
static createCode(iModel, scopeModelId, name) {
|
|
73
|
+
const codeSpec = iModel.codeSpecs.getByName(core_common_1.BisCodeSpec.texture);
|
|
74
|
+
return 0 === name.length ? core_common_1.Code.createEmpty() : new core_common_1.Code({ spec: codeSpec.id, scope: scopeModelId, value: name });
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create a RenderMaterial with given parameters.
|
|
78
|
+
* @param iModelDb The iModel
|
|
79
|
+
* @param definitionModelId The [[DefinitionModel]]
|
|
80
|
+
* @param materialName The name/CodeValue of the RenderMaterial
|
|
81
|
+
* @param params Parameters object which describes how to construct the RenderMaterial
|
|
82
|
+
* @returns The newly constructed RenderMaterial element.
|
|
83
|
+
* @throws [[IModelError]] if unable to create the element.
|
|
84
|
+
*/
|
|
85
|
+
static create(iModelDb, definitionModelId, materialName, params) {
|
|
86
|
+
const map = undefined !== params.patternMap ? { Pattern: params.patternMap } : undefined;
|
|
87
|
+
const renderMaterialProps = {
|
|
88
|
+
classFullName: this.classFullName,
|
|
89
|
+
code: this.createCode(iModelDb, definitionModelId, materialName),
|
|
90
|
+
paletteName: params.paletteName,
|
|
91
|
+
description: params.description,
|
|
92
|
+
jsonProperties: {
|
|
93
|
+
materialAssets: {
|
|
94
|
+
renderMaterial: {
|
|
95
|
+
HasBaseColor: params.color !== undefined,
|
|
96
|
+
color: params.color,
|
|
97
|
+
HasSpecularColor: params.specularColor !== undefined,
|
|
98
|
+
specular_color: params.specularColor,
|
|
99
|
+
HasFinish: params.finish !== undefined,
|
|
100
|
+
finish: params.finish,
|
|
101
|
+
HasTransmit: params.transmit !== undefined,
|
|
102
|
+
transmit: params.transmit,
|
|
103
|
+
HasDiffuse: params.diffuse !== undefined,
|
|
104
|
+
diffuse: params.diffuse,
|
|
105
|
+
HasSpecular: params.specular !== undefined,
|
|
106
|
+
specular: params.specular,
|
|
107
|
+
HasReflect: params.reflect !== undefined,
|
|
108
|
+
reflect: params.reflect,
|
|
109
|
+
HasReflectColor: params.reflectColor !== undefined,
|
|
110
|
+
reflect_color: params.reflectColor,
|
|
111
|
+
Map: map,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
model: definitionModelId,
|
|
116
|
+
isPrivate: false,
|
|
117
|
+
};
|
|
118
|
+
return new RenderMaterialElement(renderMaterialProps, iModelDb);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Insert a new RenderMaterial into a model.
|
|
122
|
+
* @param iModelDb Insert into this iModel
|
|
123
|
+
* @param definitionModelId Insert the new Texture into this DefinitionModel
|
|
124
|
+
* @param materialName The name/CodeValue of the RenderMaterial
|
|
125
|
+
* @param params Parameters object which describes how to construct the RenderMaterial
|
|
126
|
+
* @returns The Id of the newly inserted RenderMaterial element.
|
|
127
|
+
* @throws [[IModelError]] if unable to insert the element.
|
|
128
|
+
*/
|
|
129
|
+
static insert(iModelDb, definitionModelId, materialName, params) {
|
|
130
|
+
const renderMaterial = this.create(iModelDb, definitionModelId, materialName, params);
|
|
131
|
+
return iModelDb.elements.insertElement(renderMaterial.toJSON());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.RenderMaterialElement = RenderMaterialElement;
|
|
135
|
+
/** @public
|
|
136
|
+
* @note color, specularColor and reflectColor are stored as [R,G,B] where each value is between 0 and 1
|
|
137
|
+
*/
|
|
138
|
+
(function (RenderMaterialElement) {
|
|
139
|
+
/** Parameters used to construct a [[RenderMaterial]]. */
|
|
140
|
+
class Params {
|
|
141
|
+
/** Construct a new RenderMaterial.Params object with the specified paletteName. Alter the public members on that object to specify settings. */
|
|
142
|
+
constructor(paletteName) {
|
|
143
|
+
this.paletteName = paletteName;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
RenderMaterialElement.Params = Params;
|
|
147
|
+
})(RenderMaterialElement = exports.RenderMaterialElement || (exports.RenderMaterialElement = {}));
|
|
148
148
|
//# sourceMappingURL=Material.js.map
|
package/lib/cjs/Material.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Material.js","sourceRoot":"","sources":["../../src/Material.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oDAA+I;AAC/I,uCAA8C;AAG9C,yDAAyD;AAEzD;;;GAGG;AACH,MAAsB,gBAAiB,SAAQ,2BAAiB;IAC9D,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,kBAAkB,CAAC,CAAC,CAAC;IAC7E;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,MAAgB,EAAE,iBAAiC,EAAE,IAAY;QACxF,MAAM,QAAQ,GAAa,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,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CAAC,OAAO;wBACvB,WAAW,EAAE,MAAM,CAAC,QAAQ,KAAK,SAAS;wBAC1C,QAAQ,EAAE,MAAM,CAAC,QAAQ;wBACzB,UAAU,EAAE,MAAM,CAAC,OAAO,KAAK,SAAS;wBACxC,OAAO,EAAE,MAAM,CAAC,OAAO;wBACvB,eAAe,EAAE,MAAM,CAAC,YAAY,KAAK,SAAS;wBAClD,aAAa,EAAE,MAAM,CAAC,YAAY;wBAClC,GAAG,EAAE,GAAG;qBACT;iBACF;aACF;YACD,KAAK,EAAE,iBAAiB;YACxB,SAAS,EAAE,KAAK;SACjB,CAAC;QACF,OAAO,IAAI,qBAAqB,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IAClE,CAAC;IACD;;;;;;;;OAQG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,iBAA6B,EAAE,YAAoB,EAAE,MAAoC;QAChI,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;QACtF,OAAO,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AAvFD,sDAuFC;AAED;;EAEE;AACF,WAAiB,qBAAqB;IACpC,yDAAyD;IACzD,MAAa,MAAM;QAwBjB,iJAAiJ;QACjJ,YAAmB,WAAmB;YACpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QACjC,CAAC;KACF;IA5BY,4BAAM,SA4BlB,CAAA;AACH,CAAC,EA/BgB,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QA+BrC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\n\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { BisCodeSpec, Code, CodeScopeProps, CodeSpec, DefinitionElementProps, RenderMaterialProps, TextureMapProps } from \"@itwin/core-common\";\nimport { DefinitionElement } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\n\n/* eslint-disable @typescript-eslint/naming-convention */\n\n/** A PhysicalMaterial defines the matter that makes up physical elements.\n * @note See [[RenderMaterialElement]] for the DefinitionElement used to define rendering characteristics.\n * @public\n */\nexport abstract class PhysicalMaterial extends DefinitionElement {\n /** @internal */\n public static override get className(): string { return \"PhysicalMaterial\"; }\n /** Create a Code for a PhysicalMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModelDb\n * @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.\n * @param name The name (codeValue) of the PhysicalMaterial\n */\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.physicalMaterial);\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\n }\n /** Create a PhysicalMaterial\n * @param iModelDb The IModelDb\n * @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.\n * @param name The name (codeValue) of the PhysicalMaterial\n * @returns The newly constructed PhysicalMaterial\n * @throws [[IModelError]] if there is a problem creating the PhysicalMaterial\n */\n public static create<T extends PhysicalMaterial>(iModelDb: IModelDb, definitionModelId: CodeScopeProps, name: string): T {\n const elementProps: DefinitionElementProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name),\n };\n return iModelDb.elements.createElement(elementProps);\n }\n}\n\n/** Defines a rendering material.\n * @note See [[PhysicalMaterial]] for the DefinitionElement used to define the matter that makes up physical elements.\n * @public\n */\nexport class RenderMaterialElement extends DefinitionElement {\n /** @internal */\n public static override get className(): string { return \"RenderMaterial\"; }\n\n /** The name of a palette that can be used to categorize multiple materials. */\n public paletteName: string;\n /** An optional description of the material. */\n public description?: string;\n /** @internal */\n constructor(props: RenderMaterialProps, iModel: IModelDb) {\n super(props, iModel);\n this.paletteName = props.paletteName;\n this.description = props.description;\n }\n /** @internal */\n public override toJSON(): RenderMaterialProps {\n const val = super.toJSON() as RenderMaterialProps;\n val.paletteName = this.paletteName;\n val.description = this.description;\n return val;\n }\n /** Create a Code for a RenderMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModelDb\n * @param scopeModelId The Id of the DefinitionModel that contains the RenderMaterial and provides the scope for its name.\n * @param name The RenderMaterial name\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, name: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.texture);\n return 0 === name.length ? Code.createEmpty() : new Code({ spec: codeSpec.id, scope: scopeModelId, value: name });\n }\n /**\n * Create a RenderMaterial with given parameters.\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param materialName The name/CodeValue of the RenderMaterial\n * @param params Parameters object which describes how to construct the RenderMaterial\n * @returns The newly constructed RenderMaterial element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, materialName: string, params: RenderMaterialElement.Params): RenderMaterialElement {\n const map = undefined !== params.patternMap ? { Pattern: params.patternMap } : undefined;\n const renderMaterialProps: RenderMaterialProps = {\n classFullName: this.classFullName,\n code: this.createCode(iModelDb, definitionModelId, materialName),\n paletteName: params.paletteName,\n description: params.description,\n jsonProperties: {\n materialAssets: {\n renderMaterial: {\n HasBaseColor: params.color !== undefined,\n color: params.color,\n HasSpecularColor: params.specularColor !== undefined,\n specular_color: params.specularColor,\n HasFinish: params.finish !== undefined,\n finish: params.finish,\n HasTransmit: params.transmit !== undefined,\n transmit: params.transmit,\n HasDiffuse: params.diffuse !== undefined,\n diffuse: params.diffuse,\n HasSpecular: params.specular !== undefined,\n specular: params.specular,\n HasReflect: params.reflect !== undefined,\n reflect: params.reflect,\n HasReflectColor: params.reflectColor !== undefined,\n reflect_color: params.reflectColor,\n Map: map,\n },\n },\n },\n model: definitionModelId,\n isPrivate: false,\n };\n return new RenderMaterialElement(renderMaterialProps, iModelDb);\n }\n /**\n * Insert a new RenderMaterial into a model.\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new Texture into this DefinitionModel\n * @param materialName The name/CodeValue of the RenderMaterial\n * @param params Parameters object which describes how to construct the RenderMaterial\n * @returns The Id of the newly inserted RenderMaterial element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, materialName: string, params: RenderMaterialElement.Params): Id64String {\n const renderMaterial = this.create(iModelDb, definitionModelId, materialName, params);\n return iModelDb.elements.insertElement(renderMaterial.toJSON());\n }\n}\n\n/** @public\n * @note color, specularColor and reflectColor are stored as [R,G,B] where each value is between 0 and 1\n*/\nexport namespace RenderMaterialElement { // eslint-disable-line no-redeclare\n /** Parameters used to construct a [[RenderMaterial]]. */\n export class Params {\n /** The palette name which categorizes this RenderMaterial */\n public paletteName: string;\n /** The optional description for this RenderMaterial */\n public description?: string;\n /** If defined, use this color for surface fill or diffuse illumination; if undefined, defaults to black */\n public color?: number[];\n /** If defined, use this color for surface specular illumination; if undefined, defaults to black */\n public specularColor?: number[];\n /** If defined, apply this specular exponent(surface shininess); range is 0 to 128; if undefined, defaults to 15.0 * 0.9 */\n public finish?: number;\n /** If defined, apply this surface transparency; if undefined, defaults to 0.0 */\n public transmit?: number;\n /** If defined, apply this surface diffuse reflectivity; if undefined, defaults to 0.6 */\n public diffuse?: number;\n /** If defined, apply this surface specular reflectivity; if undefined, defaults to 0.0. NOTE: The actual JSON allows a HasSpecular property to be true and the specular value itself undefined, in which case the value 0.4 would be used. This API does not allow this case. */\n public specular?: number;\n /** If defined, apply this surface environmental reflectivity; stored as fraction of specular in V8 material settings; if undefined, defaults to 0.0 */\n public reflect?: number;\n /** If defined, apply this surface reflectance color; if undefined, defaults to whatever the specularColor is */\n public reflectColor?: number[];\n /** If defined, specifies the pattern mapping. */\n public patternMap?: TextureMapProps;\n\n /** Construct a new RenderMaterial.Params object with the specified paletteName. Alter the public members on that object to specify settings. */\n public constructor(paletteName: string) {\n this.paletteName = paletteName;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Material.js","sourceRoot":"","sources":["../../src/Material.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oDAA+I;AAC/I,uCAA8C;AAG9C,yDAAyD;AAEzD;;;GAGG;AACH,MAAsB,gBAAiB,SAAQ,2BAAiB;IAC9D,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,kBAAkB,CAAC,CAAC,CAAC;IAC7E;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,MAAgB,EAAE,iBAAiC,EAAE,IAAY;QACxF,MAAM,QAAQ,GAAa,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,yBAAW,CAAC,gBAAgB,CAAC,CAAC;QACpF,OAAO,IAAI,kBAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;IACD;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAA6B,QAAkB,EAAE,iBAAiC,EAAE,IAAY;QAClH,MAAM,YAAY,GAA2B;YAC3C,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC;SACzD,CAAC;QACF,OAAO,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IACvD,CAAC;CACF;AA3BD,4CA2BC;AAED;;;GAGG;AACH,MAAa,qBAAsB,SAAQ,2BAAiB;IAQ1D,gBAAgB;IAChB,YAAY,KAA0B,EAAE,MAAgB;QACt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CAAC,CAAC;QACtF,OAAO,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AAvFD,sDAuFC;AAED;;EAEE;AACF,WAAiB,qBAAqB;IACpC,yDAAyD;IACzD,MAAa,MAAM;QAwBjB,iJAAiJ;QACjJ,YAAmB,WAAmB;YACpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QACjC,CAAC;KACF;IA5BY,4BAAM,SA4BlB,CAAA;AACH,CAAC,EA/BgB,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QA+BrC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Elements\r\n */\r\n\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport { BisCodeSpec, Code, CodeScopeProps, CodeSpec, DefinitionElementProps, RenderMaterialProps, TextureMapProps } from \"@itwin/core-common\";\r\nimport { DefinitionElement } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\n\r\n/** A PhysicalMaterial defines the matter that makes up physical elements.\r\n * @note See [[RenderMaterialElement]] for the DefinitionElement used to define rendering characteristics.\r\n * @public\r\n */\r\nexport abstract class PhysicalMaterial extends DefinitionElement {\r\n /** @internal */\r\n public static override get className(): string { return \"PhysicalMaterial\"; }\r\n /** Create a Code for a PhysicalMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModelDb\r\n * @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.\r\n * @param name The name (codeValue) of the PhysicalMaterial\r\n */\r\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.physicalMaterial);\r\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\r\n }\r\n /** Create a PhysicalMaterial\r\n * @param iModelDb The IModelDb\r\n * @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.\r\n * @param name The name (codeValue) of the PhysicalMaterial\r\n * @returns The newly constructed PhysicalMaterial\r\n * @throws [[IModelError]] if there is a problem creating the PhysicalMaterial\r\n */\r\n public static create<T extends PhysicalMaterial>(iModelDb: IModelDb, definitionModelId: CodeScopeProps, name: string): T {\r\n const elementProps: DefinitionElementProps = {\r\n classFullName: this.classFullName,\r\n model: definitionModelId,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n };\r\n return iModelDb.elements.createElement(elementProps);\r\n }\r\n}\r\n\r\n/** Defines a rendering material.\r\n * @note See [[PhysicalMaterial]] for the DefinitionElement used to define the matter that makes up physical elements.\r\n * @public\r\n */\r\nexport class RenderMaterialElement extends DefinitionElement {\r\n /** @internal */\r\n public static override get className(): string { return \"RenderMaterial\"; }\r\n\r\n /** The name of a palette that can be used to categorize multiple materials. */\r\n public paletteName: string;\r\n /** An optional description of the material. */\r\n public description?: string;\r\n /** @internal */\r\n constructor(props: RenderMaterialProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.paletteName = props.paletteName;\r\n this.description = props.description;\r\n }\r\n /** @internal */\r\n public override toJSON(): RenderMaterialProps {\r\n const val = super.toJSON() as RenderMaterialProps;\r\n val.paletteName = this.paletteName;\r\n val.description = this.description;\r\n return val;\r\n }\r\n /** Create a Code for a RenderMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModelDb\r\n * @param scopeModelId The Id of the DefinitionModel that contains the RenderMaterial and provides the scope for its name.\r\n * @param name The RenderMaterial name\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, name: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.texture);\r\n return 0 === name.length ? Code.createEmpty() : new Code({ spec: codeSpec.id, scope: scopeModelId, value: name });\r\n }\r\n /**\r\n * Create a RenderMaterial with given parameters.\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param materialName The name/CodeValue of the RenderMaterial\r\n * @param params Parameters object which describes how to construct the RenderMaterial\r\n * @returns The newly constructed RenderMaterial element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, materialName: string, params: RenderMaterialElement.Params): RenderMaterialElement {\r\n const map = undefined !== params.patternMap ? { Pattern: params.patternMap } : undefined;\r\n const renderMaterialProps: RenderMaterialProps = {\r\n classFullName: this.classFullName,\r\n code: this.createCode(iModelDb, definitionModelId, materialName),\r\n paletteName: params.paletteName,\r\n description: params.description,\r\n jsonProperties: {\r\n materialAssets: {\r\n renderMaterial: {\r\n HasBaseColor: params.color !== undefined,\r\n color: params.color,\r\n HasSpecularColor: params.specularColor !== undefined,\r\n specular_color: params.specularColor,\r\n HasFinish: params.finish !== undefined,\r\n finish: params.finish,\r\n HasTransmit: params.transmit !== undefined,\r\n transmit: params.transmit,\r\n HasDiffuse: params.diffuse !== undefined,\r\n diffuse: params.diffuse,\r\n HasSpecular: params.specular !== undefined,\r\n specular: params.specular,\r\n HasReflect: params.reflect !== undefined,\r\n reflect: params.reflect,\r\n HasReflectColor: params.reflectColor !== undefined,\r\n reflect_color: params.reflectColor,\r\n Map: map,\r\n },\r\n },\r\n },\r\n model: definitionModelId,\r\n isPrivate: false,\r\n };\r\n return new RenderMaterialElement(renderMaterialProps, iModelDb);\r\n }\r\n /**\r\n * Insert a new RenderMaterial into a model.\r\n * @param iModelDb Insert into this iModel\r\n * @param definitionModelId Insert the new Texture into this DefinitionModel\r\n * @param materialName The name/CodeValue of the RenderMaterial\r\n * @param params Parameters object which describes how to construct the RenderMaterial\r\n * @returns The Id of the newly inserted RenderMaterial element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, materialName: string, params: RenderMaterialElement.Params): Id64String {\r\n const renderMaterial = this.create(iModelDb, definitionModelId, materialName, params);\r\n return iModelDb.elements.insertElement(renderMaterial.toJSON());\r\n }\r\n}\r\n\r\n/** @public\r\n * @note color, specularColor and reflectColor are stored as [R,G,B] where each value is between 0 and 1\r\n*/\r\nexport namespace RenderMaterialElement { // eslint-disable-line no-redeclare\r\n /** Parameters used to construct a [[RenderMaterial]]. */\r\n export class Params {\r\n /** The palette name which categorizes this RenderMaterial */\r\n public paletteName: string;\r\n /** The optional description for this RenderMaterial */\r\n public description?: string;\r\n /** If defined, use this color for surface fill or diffuse illumination; if undefined, defaults to black */\r\n public color?: number[];\r\n /** If defined, use this color for surface specular illumination; if undefined, defaults to black */\r\n public specularColor?: number[];\r\n /** If defined, apply this specular exponent(surface shininess); range is 0 to 128; if undefined, defaults to 15.0 * 0.9 */\r\n public finish?: number;\r\n /** If defined, apply this surface transparency; if undefined, defaults to 0.0 */\r\n public transmit?: number;\r\n /** If defined, apply this surface diffuse reflectivity; if undefined, defaults to 0.6 */\r\n public diffuse?: number;\r\n /** If defined, apply this surface specular reflectivity; if undefined, defaults to 0.0. NOTE: The actual JSON allows a HasSpecular property to be true and the specular value itself undefined, in which case the value 0.4 would be used. This API does not allow this case. */\r\n public specular?: number;\r\n /** If defined, apply this surface environmental reflectivity; stored as fraction of specular in V8 material settings; if undefined, defaults to 0.0 */\r\n public reflect?: number;\r\n /** If defined, apply this surface reflectance color; if undefined, defaults to whatever the specularColor is */\r\n public reflectColor?: number[];\r\n /** If defined, specifies the pattern mapping. */\r\n public patternMap?: TextureMapProps;\r\n\r\n /** Construct a new RenderMaterial.Params object with the specified paletteName. Alter the public members on that object to specify settings. */\r\n public constructor(paletteName: string) {\r\n this.paletteName = paletteName;\r\n }\r\n }\r\n}\r\n"]}
|