@itwin/core-backend 5.1.0-dev.65 → 5.1.0-dev.69
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/lib/cjs/ClassRegistry.d.ts +8 -0
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +8 -0
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/Material.d.ts +3 -2
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +4 -4
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Schema.d.ts +25 -0
- package/lib/cjs/Schema.d.ts.map +1 -1
- package/lib/cjs/Schema.js +25 -0
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/esm/ClassRegistry.d.ts +8 -0
- package/lib/esm/ClassRegistry.d.ts.map +1 -1
- package/lib/esm/ClassRegistry.js +8 -0
- package/lib/esm/ClassRegistry.js.map +1 -1
- package/lib/esm/Material.d.ts +3 -2
- package/lib/esm/Material.d.ts.map +1 -1
- package/lib/esm/Material.js +4 -4
- package/lib/esm/Material.js.map +1 -1
- package/lib/esm/Schema.d.ts +25 -0
- package/lib/esm/Schema.d.ts.map +1 -1
- package/lib/esm/Schema.js +25 -0
- package/lib/esm/Schema.js.map +1 -1
- package/lib/esm/test/misc/GeoServices.test.js +13 -1
- package/lib/esm/test/misc/GeoServices.test.js.map +1 -1
- package/lib/esm/test/schema/ClassRegistry.test.js +104 -2
- package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
- package/lib/esm/test/standalone/RenderMaterialElement.test.js +24 -1
- package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
- package/package.json +14 -14
|
@@ -39,6 +39,14 @@ export declare class EntityJsClassMap {
|
|
|
39
39
|
/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in "schema:class" format) and the JavaScript [[Entity]] class that implements it.
|
|
40
40
|
* Applications or modules that supply their own Entity subclasses should use [[registerModule]] or [[register]] at startup
|
|
41
41
|
* to establish their mappings.
|
|
42
|
+
*
|
|
43
|
+
* When creating custom Entity subclasses for registration, you should:
|
|
44
|
+
* - Override the `className` property to match your ECClass name:
|
|
45
|
+
* ```typescript
|
|
46
|
+
* public static override get className() { return "TestElement"; }
|
|
47
|
+
* ```
|
|
48
|
+
* - Do NOT override `schemaName` or `schema` - these will be wired up automatically during registration
|
|
49
|
+
*
|
|
42
50
|
* @public
|
|
43
51
|
*/
|
|
44
52
|
export declare class ClassRegistry {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassRegistry.d.ts","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAkB,UAAU,EAAwB,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,cAAc,EAAsB,WAAW,EAAkB,MAAM,oBAAoB,CAAC;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAW,MAAM,UAAU,CAAC;AAO3C;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoC;IAE9D,gBAAgB;IACT,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;IAI1C,gBAAgB;IACT,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,MAAM,GAAG,SAAS;IAI5D,gBAAgB;IACT,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,MAAM,GAAG,IAAI;IAInE,gBAAgB;IACT,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;IAI7C,gBAAgB;IACT,KAAK,IAAI,IAAI;IAIpB,gBAAgB;IACT,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,OAAO,M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GED
|
@@ -71,6 +71,14 @@ exports.EntityJsClassMap = EntityJsClassMap;
|
|
|
71
71
|
/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in "schema:class" format) and the JavaScript [[Entity]] class that implements it.
|
|
72
72
|
* Applications or modules that supply their own Entity subclasses should use [[registerModule]] or [[register]] at startup
|
|
73
73
|
* to establish their mappings.
|
|
74
|
+
*
|
|
75
|
+
* When creating custom Entity subclasses for registration, you should:
|
|
76
|
+
* - Override the `className` property to match your ECClass name:
|
|
77
|
+
* ```typescript
|
|
78
|
+
* public static override get className() { return "TestElement"; }
|
|
79
|
+
* ```
|
|
80
|
+
* - Do NOT override `schemaName` or `schema` - these will be wired up automatically during registration
|
|
81
|
+
*
|
|
74
82
|
* @public
|
|
75
83
|
*/
|
|
76
84
|
class ClassRegistry {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassRegistry.js","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuF;AACvF,oDAAqG;AACrG,qCAAkC;AAElC,qCAA2C;AAC3C,yDAAsD;AACtD,iCAAiC;AACjC,gDAA+C;AAE/C,MAAM,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAa,gBAAgB;IACV,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;IAE9D,gBAAgB;IACT,GAAG,CAAC,aAAqB;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,gBAAgB;IACT,GAAG,CAAC,aAAqB;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,gBAAgB;IACT,GAAG,CAAC,aAAqB,EAAE,WAA0B;QAC1D,IAAI,CAAC,SA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ACpD,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC9C,cAAc,GAAG,IAAI,GAAG,EAAsB,CAAC;IAEvD,wCAAwC;IACxC,4DAA4D;IACrD,IAAI,CAAC,aAAqB;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,4DAA4D;IACrD,aAAa,CAAC,OAAmB;QACtC,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9C,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1D,CAAC;IAED,gCAAgC;IAChC,4DAA4D;IACrD,GAAG,CAAC,aAAqB,EAAE,QAAwB;QACxD,MAAM,IAAI,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QACzC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACnC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;CACF;AAxBD,4CAwBC","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 Schema\n */\n\nimport { DbResult, Id64, Id64String, IModelStatus, Logger } from \"@itwin/core-bentley\";\nimport { EntityMetaData, EntityReferenceSet, IModelError, RelatedElement } from \"@itwin/core-common\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { Schema, Schemas } from \"./Schema\";\nimport { EntityReferences } from \"./EntityReferences\";\nimport * as assert from \"assert\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\nconst isGeneratedClassTag = Symbol(\"isGeneratedClassTag\");\n\n/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in \"schema:class\" format) and the JavaScript [[Entity]] class that implements it.\n * @public\n */\nexport class EntityJsClassMap {\n private readonly _classMap = new Map<string, typeof Entity>();\n\n /** @internal */\n public has(classFullName: string): boolean {\n return this._classMap.has(classFullName.toLowerCase());\n }\n\n /** @internal */\n public get(classFullName: string): typeof Entity | undefined {\n return this._classMap.get(classFullName.toLowerCase());\n }\n\n /** @internal */\n public set(classFullName: string, entityClass: typeof Entity): void {\n this._classMap.set(classFullName.toLowerCase(), entityClass);\n }\n\n /** @internal */\n public delete(classFullName: string): boolean {\n return this._classMap.delete(classFullName.toLowerCase());\n }\n\n /** @internal */\n public clear(): void {\n this._classMap.clear();\n }\n\n /** @internal */\n public [Symbol.iterator](): IterableIterator<[string, typeof Entity]> {\n return this._classMap[Symbol.iterator]();\n }\n\n /**\n * Registers a single `entityClass` defined in the specified `schema`.\n * This method registers the class globally. To register a class for a specific iModel, use [[IModelDb.jsClassMap]].\n *\n * @param entityClass - The JavaScript class that implements the BIS [ECClass](@itwin/core-common) to be registered.\n * @param schema - The schema that contains the `entityClass`.\n *\n * @throws Error if the class is already registered.\n *\n * @public\n */\n public register(entityClass: typeof Entity, schema: typeof Schema): void {\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\n if (this.has(key)) {\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\n throw new Error(errMsg);\n }\n entityClass.schema = schema;\n this.set(key, entityClass);\n }\n}\n\n/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in \"schema:class\" format) and the JavaScript [[Entity]] class that implements it.\n * Applications or modules that supply their own Entity subclasses should use [[registerModule]] or [[register]] at startup\n * to establish their mappings.\n * @public\n */\nexport class ClassRegistry {\n private static readonly _globalClassMap = new EntityJsClassMap();\n /** @internal */\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\n /** @internal */\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\n /** Register a single `entityClass` defined in the specified `schema`.\n * @see [[registerModule]] to register multiple classes.\n * @public\n */\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\n this._globalClassMap.register(entityClass, schema);\n }\n\n /** Generate a proxy Schema for a domain that has not been registered. */\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\n const hasBehavior = iModel.withPreparedSqliteStatement(`\n SELECT NULL FROM [ec_CustomAttribute] [c]\n JOIN [ec_schema] [s] ON [s].[Id] = [c].[ContainerId]\n JOIN [ec_class] [e] ON [e].[Id] = [c].[ClassId]\n JOIN [ec_schema] [b] ON [e].[SchemaId] = [b].[Id]\n WHERE [c].[ContainerType] = 1 AND [s].[Name] = ? AND [b].[Name] || '.' || [e].[name] = ?`, (stmt) => {\n stmt.bindString(1, domain);\n stmt.bindString(2, \"BisCore.SchemaHasBehavior\");\n return stmt.step() === DbResult.BE_SQLITE_ROW;\n });\n\n const schemaClass = class extends Schema {\n public static override get schemaName() { return domain; }\n public static override get missingRequiredBehavior() { return hasBehavior; }\n };\n\n iModel.schemaMap.registerSchema(schemaClass); // register the class before we return it.\n return schemaClass;\n }\n\n /** First, finds the root BisCore entity class for an entity, by traversing base classes and mixin targets (AppliesTo).\n * Then, gets its metadata and returns that.\n * @param iModel - iModel containing the metadata for this type\n * @param ecTypeQualifier - a full name of an ECEntityClass to find the root of\n * @returns the qualified full name of an ECEntityClass\n * @internal public for testing only\n */\n public static getRootEntity(iModel: IModelDb, ecTypeQualifier: string): string {\n const [classSchema, className] = ecTypeQualifier.split(\".\");\n const schemaItemJson = iModel[_nativeDb].getSchemaItem(classSchema, className);\n if (schemaItemJson.error)\n throw new IModelError(schemaItemJson.error.status, `failed to get schema item '${ecTypeQualifier}'`);\n\n assert(undefined !== schemaItemJson.result);\n const schemaItem = JSON.parse(schemaItemJson.result);\n if (!(\"appliesTo\" in schemaItem) && schemaItem.baseClass === undefined) {\n return ecTypeQualifier;\n }\n\n // typescript doesn't understand that the inverse of the above condition is\n // (\"appliesTo\" in rootclassMetaData || rootClassMetaData.baseClass !== undefined)\n const parentItemQualifier = schemaItem.appliesTo ?? schemaItem.baseClass as string;\n return this.getRootEntity(iModel, parentItemQualifier);\n }\n\n /** Generate a JavaScript class from Entity metadata.\n * @param entityMetaData The Entity metadata that defines the class\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\n const name = entityMetaData.ecclass.split(\":\");\n const domainName = name[0];\n const className = name[1];\n\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\n throw new IModelError(IModelStatus.BadArg, `class ${name} has no superclass`);\n\n // make sure schema exists\n let schema = iModel.schemaMap.get(domainName) ?? Schemas.getRegisteredSchema(domainName);\n if (undefined === schema)\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\n\n const superClassFullName = entityMetaData.baseClasses[0].toLowerCase();\n const superclass = iModel.jsClassMap.get(superClassFullName) ?? this._globalClassMap.get(superClassFullName);\n if (undefined === superclass)\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${name}`);\n\n // user defined class hierarchies may skip a class in the hierarchy, and therefore their JS base class cannot\n // be used to tell if there are any generated classes in the hierarchy\n let generatedClassHasNonGeneratedNonCoreAncestor = false;\n let currentSuperclass = superclass;\n const MAX_ITERS = 1000;\n for (let i = 0; i < MAX_ITERS; ++i) {\n if (currentSuperclass.schema.schemaName === \"BisCore\")\n break;\n\n if (!currentSuperclass.isGeneratedClass) {\n generatedClassHasNonGeneratedNonCoreAncestor = true;\n break;\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const superclassMetaData = iModel.classMetaDataRegistry.find(currentSuperclass.classFullName);\n if (superclassMetaData === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the metadata for class '${currentSuperclass.name}', class metadata should be loaded by now`);\n const maybeNextSuperclass = this.getClass(superclassMetaData.baseClasses[0], iModel);\n if (maybeNextSuperclass === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the base class of '${currentSuperclass.name}', all generated classes must have a base class`);\n currentSuperclass = maybeNextSuperclass;\n }\n\n const generatedClass = class extends superclass {\n public static override get className() { return className; }\n private static [isGeneratedClassTag] = true;\n public static override get isGeneratedClass() { return this.hasOwnProperty(isGeneratedClassTag); }\n };\n\n // the above creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\n\n // a class only gets an automatic `collectReferenceIds` implementation if:\n // - it is not in the `BisCore` schema\n // - there are no ancestors with manually registered JS implementations, (excluding BisCore base classes)\n if (!generatedClassHasNonGeneratedNonCoreAncestor) {\n const navigationProps = Object.entries(entityMetaData.properties)\n .filter(([_name, prop]) => prop.isNavigation)\n // eslint-disable-next-line @typescript-eslint/no-shadow\n .map(([name, prop]) => {\n assert(prop.relationshipClass);\n const maybeMetaData = iModel[_nativeDb].getSchemaItem(...prop.relationshipClass.split(\":\") as [string, string]);\n assert(maybeMetaData.result !== undefined, \"The nav props relationship metadata was not found\");\n const relMetaData = JSON.parse(maybeMetaData.result);\n const rootClassMetaData = ClassRegistry.getRootEntity(iModel, relMetaData.target.constraintClasses[0]);\n // root class must be in BisCore so should be loaded since biscore classes will never get this\n // generated implementation\n const normalizeClassName = (clsName: string) => clsName.replace(\".\", \":\");\n const rootClass = ClassRegistry.findRegisteredClass(normalizeClassName(rootClassMetaData));\n assert(rootClass, `The root class for ${prop.relationshipClass} was not in BisCore.`);\n return { name, concreteEntityType: EntityReferences.typeFromClass(rootClass) };\n });\n\n Object.defineProperty(\n generatedClass.prototype,\n \"collectReferenceIds\",\n {\n value(this: typeof generatedClass, referenceIds: EntityReferenceSet) {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n const superImpl = superclass.prototype[\"collectReferenceIds\"];\n superImpl.call(this, referenceIds);\n for (const navProp of navigationProps) {\n const relatedElem: RelatedElement | undefined = (this as any)[navProp.name]; // cast to any since subclass can have any extensions\n if (!relatedElem || !Id64.isValid(relatedElem.id))\n continue;\n const referenceId = EntityReferences.fromEntityType(relatedElem.id, navProp.concreteEntityType);\n referenceIds.add(referenceId);\n }\n },\n // defaults for methods on a prototype (required for sinon to stub out methods on tests)\n writable: true,\n configurable: true,\n },\n );\n }\n\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\n if (schema.missingRequiredBehavior) {\n const throwError = () => {\n throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`);\n };\n\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\n }\n\n iModel.jsClassMap.register(generatedClass, schema); // register it before returning\n return generatedClass;\n }\n\n /** Register all of the classes found in the given module that derive from [[Entity]].\n * [[register]] will be invoked for each subclass of `Entity` exported by `moduleObj`.\n * @param moduleObj The module to search for subclasses of Entity\n * @param schema The schema that contains all of the [ECClass]($ecschema-metadata)es exported by `moduleObj`.\n */\n public static registerModule(moduleObj: any, schema: typeof Schema) {\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\n const thisClass = moduleObj[thisMember];\n if (thisClass.prototype instanceof Entity)\n this.register(thisClass, schema);\n }\n }\n\n /**\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\n */\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\n if (metadata === undefined || metadata.ecclass === undefined)\n throw this.makeMetaDataNotFoundError(classFullName);\n\n // Make sure we have all base classes registered.\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\n this.getClass(metadata.baseClasses[0], iModel);\n\n // Now we can generate the class from the classDef.\n return this.generateClassForEntity(metadata, iModel);\n }\n\n /** Find a registered class by classFullName.\n * @param classFullName class to find\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class or undefined\n */\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\n return this._globalClassMap.get(classFullName.toLowerCase());\n }\n\n /** Get the Entity class for the specified Entity className.\n * @param classFullName The full BIS class name of the Entity\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class\n */\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\n const key = classFullName.toLowerCase();\n return iModel.jsClassMap.get(key) ?? this._globalClassMap.get(key) ?? this.generateClass(key, iModel);\n }\n\n /** Unregister a class, by name, if one is already registered.\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\n * @param classFullName Name of the class to unregister\n * @return true if the class was unregistered\n * @internal\n */\n public static unregisterClass(classFullName: string) { return this._globalClassMap.delete(classFullName.toLowerCase()); }\n\n /** Unregister all classes from a schema.\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\n * @param schema Name of the schema to unregister\n * @internal\n */\n public static unregisterClassesFrom(schema: typeof Schema) {\n for (const entry of Array.from(this._globalClassMap)) {\n if (entry[1].schema === schema)\n this.unregisterClass(entry[0]);\n }\n }\n}\n\n/**\n * A cache that records the mapping between class names and class metadata.\n * @see [[IModelDb.classMetaDataRegistry]] to access the registry for a specific iModel.\n * @internal\n * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `schemaContext` from the `iModel` instead.\n *\n * @example\n * @\n * Current Usage:\n * ```ts\n * const metaData: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(\"SchemaName:ClassName\");\n * ```\n *\n * Replacement:\n * ```ts\n * const entityMetaData: EntityClass | undefined = iModel.schemaContext.getSchemaItemSync(\"SchemaName.ClassName\", EntityClass);\n * const relationshipMetaData: RelationshipClass | undefined = iModel.schemaContext.getSchemaItemSync(\"SchemaName\", \"ClassName\", RelationshipClass);\n * ```\n */\nexport class MetaDataRegistry {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private _registry = new Map<string, EntityMetaData>();\n private _classIdToName = new Map<Id64String, string>();\n\n /** Get the specified Entity metadata */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public find(classFullName: string): EntityMetaData | undefined {\n return this._registry.get(classFullName.toLowerCase());\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public findByClassId(classId: Id64String): EntityMetaData | undefined {\n const name = this._classIdToName.get(classId);\n return undefined !== name ? this.find(name) : undefined;\n }\n\n /** Add metadata to the cache */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public add(classFullName: string, metaData: EntityMetaData): void {\n const name = classFullName.toLowerCase();\n this._registry.set(name, metaData);\n this._classIdToName.set(metaData.classId, name);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ClassRegistry.js","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuF;AACvF,oDAAqG;AACrG,qCAAkC;AAElC,qCAA2C;AAC3C,yDAAsD;AACtD,iCAAiC;AACjC,gDAA+C;AAE/C,MAAM,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAa,gBAAgB;IACV,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;IAE9D,gBAAgB;IACT,GAAG,CAAC,aAAqB;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,gBAAgB;IACT,GAAG,CAAC,aAAqB;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,gBAAgB;IACT,GAAG,CAAC,aAAqB,EAAE,WAA0B;QA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Aa,gBAAgB;IAC3B,4DAA4D;IACpD,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC9C,cAAc,GAAG,IAAI,GAAG,EAAsB,CAAC;IAEvD,wCAAwC;IACxC,4DAA4D;IACrD,IAAI,CAAC,aAAqB;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,4DAA4D;IACrD,aAAa,CAAC,OAAmB;QACtC,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9C,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1D,CAAC;IAED,gCAAgC;IAChC,4DAA4D;IACrD,GAAG,CAAC,aAAqB,EAAE,QAAwB;QACxD,MAAM,IAAI,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QACzC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACnC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;CACF;AAxBD,4CAwBC","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 Schema\n */\n\nimport { DbResult, Id64, Id64String, IModelStatus, Logger } from \"@itwin/core-bentley\";\nimport { EntityMetaData, EntityReferenceSet, IModelError, RelatedElement } from \"@itwin/core-common\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { Schema, Schemas } from \"./Schema\";\nimport { EntityReferences } from \"./EntityReferences\";\nimport * as assert from \"assert\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\nconst isGeneratedClassTag = Symbol(\"isGeneratedClassTag\");\n\n/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in \"schema:class\" format) and the JavaScript [[Entity]] class that implements it.\n * @public\n */\nexport class EntityJsClassMap {\n private readonly _classMap = new Map<string, typeof Entity>();\n\n /** @internal */\n public has(classFullName: string): boolean {\n return this._classMap.has(classFullName.toLowerCase());\n }\n\n /** @internal */\n public get(classFullName: string): typeof Entity | undefined {\n return this._classMap.get(classFullName.toLowerCase());\n }\n\n /** @internal */\n public set(classFullName: string, entityClass: typeof Entity): void {\n this._classMap.set(classFullName.toLowerCase(), entityClass);\n }\n\n /** @internal */\n public delete(classFullName: string): boolean {\n return this._classMap.delete(classFullName.toLowerCase());\n }\n\n /** @internal */\n public clear(): void {\n this._classMap.clear();\n }\n\n /** @internal */\n public [Symbol.iterator](): IterableIterator<[string, typeof Entity]> {\n return this._classMap[Symbol.iterator]();\n }\n\n /**\n * Registers a single `entityClass` defined in the specified `schema`.\n * This method registers the class globally. To register a class for a specific iModel, use [[IModelDb.jsClassMap]].\n *\n * @param entityClass - The JavaScript class that implements the BIS [ECClass](@itwin/core-common) to be registered.\n * @param schema - The schema that contains the `entityClass`.\n *\n * @throws Error if the class is already registered.\n *\n * @public\n */\n public register(entityClass: typeof Entity, schema: typeof Schema): void {\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\n if (this.has(key)) {\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\n throw new Error(errMsg);\n }\n entityClass.schema = schema;\n this.set(key, entityClass);\n }\n}\n\n/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in \"schema:class\" format) and the JavaScript [[Entity]] class that implements it.\n * Applications or modules that supply their own Entity subclasses should use [[registerModule]] or [[register]] at startup\n * to establish their mappings.\n *\n * When creating custom Entity subclasses for registration, you should:\n * - Override the `className` property to match your ECClass name:\n * ```typescript\n * public static override get className() { return \"TestElement\"; }\n * ```\n * - Do NOT override `schemaName` or `schema` - these will be wired up automatically during registration\n *\n * @public\n */\nexport class ClassRegistry {\n private static readonly _globalClassMap = new EntityJsClassMap();\n /** @internal */\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\n /** @internal */\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\n /** Register a single `entityClass` defined in the specified `schema`.\n * @see [[registerModule]] to register multiple classes.\n * @public\n */\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\n this._globalClassMap.register(entityClass, schema);\n }\n\n /** Generate a proxy Schema for a domain that has not been registered. */\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\n const hasBehavior = iModel.withPreparedSqliteStatement(`\n SELECT NULL FROM [ec_CustomAttribute] [c]\n JOIN [ec_schema] [s] ON [s].[Id] = [c].[ContainerId]\n JOIN [ec_class] [e] ON [e].[Id] = [c].[ClassId]\n JOIN [ec_schema] [b] ON [e].[SchemaId] = [b].[Id]\n WHERE [c].[ContainerType] = 1 AND [s].[Name] = ? AND [b].[Name] || '.' || [e].[name] = ?`, (stmt) => {\n stmt.bindString(1, domain);\n stmt.bindString(2, \"BisCore.SchemaHasBehavior\");\n return stmt.step() === DbResult.BE_SQLITE_ROW;\n });\n\n const schemaClass = class extends Schema {\n public static override get schemaName() { return domain; }\n public static override get missingRequiredBehavior() { return hasBehavior; }\n };\n\n iModel.schemaMap.registerSchema(schemaClass); // register the class before we return it.\n return schemaClass;\n }\n\n /** First, finds the root BisCore entity class for an entity, by traversing base classes and mixin targets (AppliesTo).\n * Then, gets its metadata and returns that.\n * @param iModel - iModel containing the metadata for this type\n * @param ecTypeQualifier - a full name of an ECEntityClass to find the root of\n * @returns the qualified full name of an ECEntityClass\n * @internal public for testing only\n */\n public static getRootEntity(iModel: IModelDb, ecTypeQualifier: string): string {\n const [classSchema, className] = ecTypeQualifier.split(\".\");\n const schemaItemJson = iModel[_nativeDb].getSchemaItem(classSchema, className);\n if (schemaItemJson.error)\n throw new IModelError(schemaItemJson.error.status, `failed to get schema item '${ecTypeQualifier}'`);\n\n assert(undefined !== schemaItemJson.result);\n const schemaItem = JSON.parse(schemaItemJson.result);\n if (!(\"appliesTo\" in schemaItem) && schemaItem.baseClass === undefined) {\n return ecTypeQualifier;\n }\n\n // typescript doesn't understand that the inverse of the above condition is\n // (\"appliesTo\" in rootclassMetaData || rootClassMetaData.baseClass !== undefined)\n const parentItemQualifier = schemaItem.appliesTo ?? schemaItem.baseClass as string;\n return this.getRootEntity(iModel, parentItemQualifier);\n }\n\n /** Generate a JavaScript class from Entity metadata.\n * @param entityMetaData The Entity metadata that defines the class\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\n const name = entityMetaData.ecclass.split(\":\");\n const domainName = name[0];\n const className = name[1];\n\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\n throw new IModelError(IModelStatus.BadArg, `class ${name} has no superclass`);\n\n // make sure schema exists\n let schema = iModel.schemaMap.get(domainName) ?? Schemas.getRegisteredSchema(domainName);\n if (undefined === schema)\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\n\n const superClassFullName = entityMetaData.baseClasses[0].toLowerCase();\n const superclass = iModel.jsClassMap.get(superClassFullName) ?? this._globalClassMap.get(superClassFullName);\n if (undefined === superclass)\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${name}`);\n\n // user defined class hierarchies may skip a class in the hierarchy, and therefore their JS base class cannot\n // be used to tell if there are any generated classes in the hierarchy\n let generatedClassHasNonGeneratedNonCoreAncestor = false;\n let currentSuperclass = superclass;\n const MAX_ITERS = 1000;\n for (let i = 0; i < MAX_ITERS; ++i) {\n if (currentSuperclass.schema.schemaName === \"BisCore\")\n break;\n\n if (!currentSuperclass.isGeneratedClass) {\n generatedClassHasNonGeneratedNonCoreAncestor = true;\n break;\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const superclassMetaData = iModel.classMetaDataRegistry.find(currentSuperclass.classFullName);\n if (superclassMetaData === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the metadata for class '${currentSuperclass.name}', class metadata should be loaded by now`);\n const maybeNextSuperclass = this.getClass(superclassMetaData.baseClasses[0], iModel);\n if (maybeNextSuperclass === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the base class of '${currentSuperclass.name}', all generated classes must have a base class`);\n currentSuperclass = maybeNextSuperclass;\n }\n\n const generatedClass = class extends superclass {\n public static override get className() { return className; }\n private static [isGeneratedClassTag] = true;\n public static override get isGeneratedClass() { return this.hasOwnProperty(isGeneratedClassTag); }\n };\n\n // the above creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\n\n // a class only gets an automatic `collectReferenceIds` implementation if:\n // - it is not in the `BisCore` schema\n // - there are no ancestors with manually registered JS implementations, (excluding BisCore base classes)\n if (!generatedClassHasNonGeneratedNonCoreAncestor) {\n const navigationProps = Object.entries(entityMetaData.properties)\n .filter(([_name, prop]) => prop.isNavigation)\n // eslint-disable-next-line @typescript-eslint/no-shadow\n .map(([name, prop]) => {\n assert(prop.relationshipClass);\n const maybeMetaData = iModel[_nativeDb].getSchemaItem(...prop.relationshipClass.split(\":\") as [string, string]);\n assert(maybeMetaData.result !== undefined, \"The nav props relationship metadata was not found\");\n const relMetaData = JSON.parse(maybeMetaData.result);\n const rootClassMetaData = ClassRegistry.getRootEntity(iModel, relMetaData.target.constraintClasses[0]);\n // root class must be in BisCore so should be loaded since biscore classes will never get this\n // generated implementation\n const normalizeClassName = (clsName: string) => clsName.replace(\".\", \":\");\n const rootClass = ClassRegistry.findRegisteredClass(normalizeClassName(rootClassMetaData));\n assert(rootClass, `The root class for ${prop.relationshipClass} was not in BisCore.`);\n return { name, concreteEntityType: EntityReferences.typeFromClass(rootClass) };\n });\n\n Object.defineProperty(\n generatedClass.prototype,\n \"collectReferenceIds\",\n {\n value(this: typeof generatedClass, referenceIds: EntityReferenceSet) {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n const superImpl = superclass.prototype[\"collectReferenceIds\"];\n superImpl.call(this, referenceIds);\n for (const navProp of navigationProps) {\n const relatedElem: RelatedElement | undefined = (this as any)[navProp.name]; // cast to any since subclass can have any extensions\n if (!relatedElem || !Id64.isValid(relatedElem.id))\n continue;\n const referenceId = EntityReferences.fromEntityType(relatedElem.id, navProp.concreteEntityType);\n referenceIds.add(referenceId);\n }\n },\n // defaults for methods on a prototype (required for sinon to stub out methods on tests)\n writable: true,\n configurable: true,\n },\n );\n }\n\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\n if (schema.missingRequiredBehavior) {\n const throwError = () => {\n throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`);\n };\n\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\n }\n\n iModel.jsClassMap.register(generatedClass, schema); // register it before returning\n return generatedClass;\n }\n\n /** Register all of the classes found in the given module that derive from [[Entity]].\n * [[register]] will be invoked for each subclass of `Entity` exported by `moduleObj`.\n * @param moduleObj The module to search for subclasses of Entity\n * @param schema The schema that contains all of the [ECClass]($ecschema-metadata)es exported by `moduleObj`.\n */\n public static registerModule(moduleObj: any, schema: typeof Schema) {\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\n const thisClass = moduleObj[thisMember];\n if (thisClass.prototype instanceof Entity)\n this.register(thisClass, schema);\n }\n }\n\n /**\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\n */\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\n if (metadata === undefined || metadata.ecclass === undefined)\n throw this.makeMetaDataNotFoundError(classFullName);\n\n // Make sure we have all base classes registered.\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\n this.getClass(metadata.baseClasses[0], iModel);\n\n // Now we can generate the class from the classDef.\n return this.generateClassForEntity(metadata, iModel);\n }\n\n /** Find a registered class by classFullName.\n * @param classFullName class to find\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class or undefined\n */\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\n return this._globalClassMap.get(classFullName.toLowerCase());\n }\n\n /** Get the Entity class for the specified Entity className.\n * @param classFullName The full BIS class name of the Entity\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class\n */\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\n const key = classFullName.toLowerCase();\n return iModel.jsClassMap.get(key) ?? this._globalClassMap.get(key) ?? this.generateClass(key, iModel);\n }\n\n /** Unregister a class, by name, if one is already registered.\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\n * @param classFullName Name of the class to unregister\n * @return true if the class was unregistered\n * @internal\n */\n public static unregisterClass(classFullName: string) { return this._globalClassMap.delete(classFullName.toLowerCase()); }\n\n /** Unregister all classes from a schema.\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\n * @param schema Name of the schema to unregister\n * @internal\n */\n public static unregisterClassesFrom(schema: typeof Schema) {\n for (const entry of Array.from(this._globalClassMap)) {\n if (entry[1].schema === schema)\n this.unregisterClass(entry[0]);\n }\n }\n}\n\n/**\n * A cache that records the mapping between class names and class metadata.\n * @see [[IModelDb.classMetaDataRegistry]] to access the registry for a specific iModel.\n * @internal\n * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `schemaContext` from the `iModel` instead.\n *\n * @example\n * @\n * Current Usage:\n * ```ts\n * const metaData: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(\"SchemaName:ClassName\");\n * ```\n *\n * Replacement:\n * ```ts\n * const entityMetaData: EntityClass | undefined = iModel.schemaContext.getSchemaItemSync(\"SchemaName.ClassName\", EntityClass);\n * const relationshipMetaData: RelationshipClass | undefined = iModel.schemaContext.getSchemaItemSync(\"SchemaName\", \"ClassName\", RelationshipClass);\n * ```\n */\nexport class MetaDataRegistry {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private _registry = new Map<string, EntityMetaData>();\n private _classIdToName = new Map<Id64String, string>();\n\n /** Get the specified Entity metadata */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public find(classFullName: string): EntityMetaData | undefined {\n return this._registry.get(classFullName.toLowerCase());\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public findByClassId(classId: Id64String): EntityMetaData | undefined {\n const name = this._classIdToName.get(classId);\n return undefined !== name ? this.find(name) : undefined;\n }\n\n /** Add metadata to the cache */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public add(classFullName: string, metaData: EntityMetaData): void {\n const name = classFullName.toLowerCase();\n this._registry.set(name, metaData);\n this._classIdToName.set(metaData.classId, name);\n }\n}\n"]}
|
package/lib/cjs/Material.d.ts
CHANGED
|
@@ -108,8 +108,9 @@ export declare namespace RenderMaterialElement {
|
|
|
108
108
|
*/
|
|
109
109
|
finish?: number;
|
|
110
110
|
/** A transparency to be applied to the surface, ranging from 0 (fully opaque) to 1 (fully transparent).
|
|
111
|
-
*
|
|
112
|
-
*
|
|
111
|
+
* If defined, then the material transparency overrides the transparency of whatever surface the material is applied to.
|
|
112
|
+
* If undefined, the material has no effect on surface transparency.
|
|
113
|
+
* Default: undefined.
|
|
113
114
|
*/
|
|
114
115
|
transmit?: number;
|
|
115
116
|
/** The surface's diffuse reflectivity from 0.0 to 1.0. Default: 0.6. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Material.d.ts","sourceRoot":"","sources":["../../src/Material.ts"],"names":[],"mappings":"AAIA;;GAE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AE,MAAM,CAAC;QACzB,wEAAwE;QACjE,OAAO,CAAC,EAAE,MAAM,CAAC;QACxB,yEAAyE;QAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;QACzB,wBAAwB;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACxB,wBAAwB;QACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QAC/B;;;WAGG;QACI,UAAU,CAAC,EAAE,eAAe,CAAC;QACpC;;;;WAIG;QACI,SAAS,CAAC,EAAE,cAAc,GAAG;YAClC;;eAEG;YACH,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;QAEF,gJAAgJ;oBAC7H,WAAW,EAAE,MAAM;KAGvC;CACF;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA4B,SAAQ,qBAAqB,CAAC,MAAM;CAChF"}
|
package/lib/cjs/Material.js
CHANGED
|
@@ -148,7 +148,6 @@ class RenderMaterialElement extends Element_1.DefinitionElement {
|
|
|
148
148
|
delete maps.Normal.scale;
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
// const map = undefined !== params.patternMap ? { Pattern: params.patternMap } : undefined;
|
|
152
151
|
const renderMaterialProps = {
|
|
153
152
|
classFullName: this.classFullName,
|
|
154
153
|
code: this.createCode(iModelDb, definitionModelId, materialName),
|
|
@@ -163,7 +162,7 @@ class RenderMaterialElement extends Element_1.DefinitionElement {
|
|
|
163
162
|
specular_color: params.specularColor,
|
|
164
163
|
HasFinish: params.finish !== undefined,
|
|
165
164
|
finish: params.finish,
|
|
166
|
-
HasTransmit: params.transmit !== undefined,
|
|
165
|
+
HasTransmit: params.transmit !== undefined ? true : undefined,
|
|
167
166
|
transmit: params.transmit,
|
|
168
167
|
HasDiffuse: params.diffuse !== undefined,
|
|
169
168
|
diffuse: params.diffuse,
|
|
@@ -236,8 +235,9 @@ exports.RenderMaterialElement = RenderMaterialElement;
|
|
|
236
235
|
*/
|
|
237
236
|
finish;
|
|
238
237
|
/** A transparency to be applied to the surface, ranging from 0 (fully opaque) to 1 (fully transparent).
|
|
239
|
-
*
|
|
240
|
-
*
|
|
238
|
+
* If defined, then the material transparency overrides the transparency of whatever surface the material is applied to.
|
|
239
|
+
* If undefined, the material has no effect on surface transparency.
|
|
240
|
+
* Default: undefined.
|
|
241
241
|
*/
|
|
242
242
|
transmit;
|
|
243
243
|
/** The surface's diffuse reflectivity from 0.0 to 1.0. Default: 0.6. */
|
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;;;AAEH,sDAAkE;AAClE,oDAE4B;AAC5B,uCAA8C;AAK9C,yDAAyD;AAEzD;;;GAGG;AACH,MAAsB,gBAAiB,SAAQ,2BAAiB;IACvD,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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CAAU;QACxB,wBAAwB;QACjB,YAAY,CAAY;QAC/B;;;WAGG;QACI,UAAU,CAAmB;QACpC;;;;WAIG;QACI,SAAS,CAKd;QAEF,gJAAgJ;QAChJ,YAAmB,WAAmB;YACpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QACjC,CAAC;KACF;IA/CY,4BAAM,SA+ClB,CAAA;AACH,CAAC,EAtDgB,qBAAqB,qCAArB,qBAAqB,QAsDrC","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 { Id64, Id64String, JsonUtils } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec, Code, CodeScopeProps, CodeSpec, DefinitionElementProps, ElementProps, NormalMapProps, RenderMaterialAssetMapsProps, RenderMaterialProps, RgbFactorProps, TextureMapProps,\n} from \"@itwin/core-common\";\nimport { DefinitionElement } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { IModelElementCloneContext } from \"./IModelElementCloneContext\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\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 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 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\n private constructor(props: RenderMaterialProps, iModel: IModelDb) {\n super(props, iModel);\n this.paletteName = props.paletteName;\n this.description = props.description;\n }\n\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\n /**\n * RenderMaterialElement custom HandledProps includes 'paletteName'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"paletteName\", source: \"Class\" },\n ];\n\n /**\n * RenderMaterialElement deserializes 'paletteName'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): RenderMaterialProps {\n const elProps = super.deserialize(props) as RenderMaterialProps;\n const instance = props.row;\n elProps.paletteName = JsonUtils.asString(instance.paletteName);\n return elProps;\n }\n\n /**\n * RenderMaterialElement serializes 'paletteName'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: RenderMaterialProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n inst.paletteName = props.paletteName;\n return inst;\n }\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.renderMaterial);\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: RenderMaterialElementParams): RenderMaterialElement {\n let maps: RenderMaterialAssetMapsProps | undefined;\n const pbr_normal = params.normalMap?.scale;\n if (params.patternMap || params.normalMap) {\n // If both normal and pattern map are present, their texture mapping modes, angles, scales, etc are expected to match.\n type TexMap = Omit<TextureMapProps, \"TextureId\">;\n function choose<K extends keyof TexMap>(obj: TexMap, key: K): void {\n const pat = params.patternMap;\n if (pat && undefined !== pat[key])\n obj[key] = pat[key];\n else if (params.normalMap && undefined !== params.normalMap[key])\n obj[key] = params.normalMap[key];\n }\n\n const baseProps: TexMap = {};\n choose(baseProps, \"pattern_angle\");\n choose(baseProps, \"pattern_u_flip\");\n choose(baseProps, \"pattern_flip\");\n choose(baseProps, \"pattern_scale\");\n choose(baseProps, \"pattern_offset\");\n choose(baseProps, \"pattern_scalemode\");\n choose(baseProps, \"pattern_mapping\");\n choose(baseProps, \"pattern_weight\");\n choose(baseProps, \"pattern_useconstantlod\");\n choose(baseProps, \"pattern_constantlod_repetitions\");\n choose(baseProps, \"pattern_constantlod_offset\");\n choose(baseProps, \"pattern_constantlod_mindistanceclamp\");\n choose(baseProps, \"pattern_constantlod_maxdistanceclamp\");\n\n maps = {};\n if (params.patternMap)\n maps.Pattern = { ...params.patternMap, ...baseProps };\n\n if (params.normalMap) {\n maps.Normal = {\n ...params.normalMap,\n ...baseProps,\n };\n\n delete (maps.Normal as any).scale;\n }\n }\n\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: maps,\n pbr_normal,\n },\n },\n },\n model: definitionModelId,\n isPrivate: false,\n };\n\n return new RenderMaterialElement(renderMaterialProps, iModelDb);\n }\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: RenderMaterialElementParams): Id64String {\n const renderMaterial = this.create(iModelDb, definitionModelId, materialName, params);\n return iModelDb.elements.insertElement(renderMaterial.toJSON());\n }\n\n /** @beta */\n protected static override onCloned(context: IModelElementCloneContext, sourceProps: ElementProps, targetProps: ElementProps) {\n super.onCloned(context, sourceProps, targetProps);\n for (const mapName in sourceProps.jsonProperties?.materialAssets?.renderMaterial?.Map ?? {}) {\n if (typeof mapName !== \"string\")\n continue;\n const sourceMap = sourceProps.jsonProperties.materialAssets.renderMaterial.Map[mapName];\n // sourceMap could be null/undefined, keep it the same in targetProps\n if (!sourceMap) {\n targetProps.jsonProperties.materialAssets.renderMaterial.Map[mapName] = sourceMap;\n continue;\n }\n if (!Id64.isValid(sourceMap.TextureId) || sourceMap.TextureId === undefined)\n continue;\n targetProps.jsonProperties.materialAssets.renderMaterial.Map[mapName].TextureId = context.findTargetElementId(sourceMap.TextureId ?? Id64.invalid);\n }\n }\n}\n\n/** @public */\nexport namespace RenderMaterialElement {\n /** Parameters used to construct a [[RenderMaterial]].\n * The persistent JSON representation - [RenderMaterialAssetProps]($common) - is quite verbose and unwieldy. This representation simplifies it somewhat.\n * @see [[RenderMaterialElement.create]] and [[RenderMaterialElement.insert]] to create a [[RenderMaterial]] from parameters of this type.\n * @deprecated in 3.6 - might be removed in next major version. Because it is not useful to use a `class` - just use [[RenderMaterialElementParams]] directly instead.\n */\n export class Params {\n /** A required palette name that categorizes this RenderMaterial */\n public paletteName: string;\n /** An optional description of this RenderMaterial */\n public description?: string;\n /** If defined, the color to use for surface fill or diffuse illumination, overriding the surface's own color. */\n public color?: RgbFactorProps;\n /** The color to use for specular illumination. Default: black. */\n public specularColor?: RgbFactorProps;\n /** The specular exponent describing the surface's shininess, in the range 0 through 128.\n * Default: 0.\n */\n public finish?: number;\n /** A transparency to be applied to the surface, ranging from 0 (fully opaque) to 1 (fully transparent).\n * The surface's own transparency will be multiplied by `(1 - transmit)`. permitting the material to increase but not decrease the surface transparency.\n * Default: 13.5.\n */\n public transmit?: number;\n /** The surface's diffuse reflectivity from 0.0 to 1.0. Default: 0.6. */\n public diffuse?: number;\n /** The surface's specular reflectivity from 0.0 to 1.0. Default: 0.0. */\n public specular?: number;\n /** Currently unused. */\n public reflect?: number;\n /** Currently unused. */\n public reflectColor?: number[];\n /** Specifies a texture image to map onto the surface, replacing or mixing with the surface's own color and transparency.\n * @note With the exception of `TextureId`, the [TextureMapProps]($common) of [[patternMap]] and [[normalMap]] are expected to be identical. If a property is defined in both\n * [[patternMap]]] and [[normalMap]], the value in [[patternMap]] takes precedence.\n */\n public patternMap?: TextureMapProps;\n /** Specifies a [normal map](https://en.wikipedia.org/wiki/Normal_mapping) to apply to the surface to simulate more surface detail than is present in the\n * surface's geometry.\n * @note With the exception of `TextureId`, the [TextureMapProps]($common) of [[patternMap]] and [[normalMap]] are expected to be identical. If a property is defined in both\n * [[patternMap]]] and [[normalMap]], the value in [[patternMap]] takes precedence.\n */\n public normalMap?: NormalMapProps & {\n /** A factor by which to multiply the components of the normal vectors read from the texture.\n * Default: 1.\n */\n scale?: number;\n };\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\n/** Parameters used to create a [[RenderMaterial]] element.\n * The persistent JSON representation - [RenderMaterialAssetProps]($common) - is quite verbose and unwieldy. This representation simplifies it somewhat.\n * @see [[RenderMaterialElement.create]] and [[RenderMaterialElement.insert]] to create a [[RenderMaterial]] from parameters of this type.\n * @public\n */\nexport interface RenderMaterialElementParams extends RenderMaterialElement.Params { // eslint-disable-line @typescript-eslint/no-deprecated, @typescript-eslint/no-empty-object-type\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Material.js","sourceRoot":"","sources":["../../src/Material.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAkE;AAClE,oDAE4B;AAC5B,uCAA8C;AAK9C,yDAAyD;AAEzD;;;GAGG;AACH,MAAsB,gBAAiB,SAAQ,2BAAiB;IACvD,MAAM,KAAc,SAAS,KAAa,OAAO,kBAAkB,CAAC,CAAC,CAAC;IAC7E;;;;OAIG;IACI,MAAM,CAAC,UAAU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AS,CAAC,IAAI,SAAS,CAAC,SAAS,KAAK,SAAS;gBACzE,SAAS;YACX,WAAW,CAAC,cAAc,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,SAAS,IAAI,mBAAI,CAAC,OAAO,CAAC,CAAC;QACrJ,CAAC;IACH,CAAC;;AApLH,sDAqLC;AAED,cAAc;AACd,WAAiB,qBAAqB;IACpC;;;;OAIG;IACH,MAAa,MAAM;QACjB,mEAAmE;QAC5D,WAAW,CAAS;QAC3B,qDAAqD;QAC9C,WAAW,CAAU;QAC5B,iHAAiH;QAC1G,KAAK,CAAkB;QAC9B,kEAAkE;QAC3D,aAAa,CAAkB;QACtC;;WAEG;QACI,MAAM,CAAU;QACvB;;;;WAIG;QACI,QAAQ,CAAU;QACzB,wEAAwE;QACjE,OAAO,CAAU;QACxB,yEAAyE;QAClE,QAAQ,CAAU;QACzB,wBAAwB;QACjB,OAAO,CAAU;QACxB,wBAAwB;QACjB,YAAY,CAAY;QAC/B;;;WAGG;QACI,UAAU,CAAmB;QACpC;;;;WAIG;QACI,SAAS,CAKd;QAEF,gJAAgJ;QAChJ,YAAmB,WAAmB;YACpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QACjC,CAAC;KACF;IAhDY,4BAAM,SAgDlB,CAAA;AACH,CAAC,EAvDgB,qBAAqB,qCAArB,qBAAqB,QAuDrC","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 { Id64, Id64String, JsonUtils } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec, Code, CodeScopeProps, CodeSpec, DefinitionElementProps, ElementProps, NormalMapProps, RenderMaterialAssetMapsProps, RenderMaterialProps, RgbFactorProps, TextureMapProps,\n} from \"@itwin/core-common\";\nimport { DefinitionElement } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { IModelElementCloneContext } from \"./IModelElementCloneContext\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\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 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 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\n private constructor(props: RenderMaterialProps, iModel: IModelDb) {\n super(props, iModel);\n this.paletteName = props.paletteName;\n this.description = props.description;\n }\n\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\n /**\n * RenderMaterialElement custom HandledProps includes 'paletteName'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"paletteName\", source: \"Class\" },\n ];\n\n /**\n * RenderMaterialElement deserializes 'paletteName'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): RenderMaterialProps {\n const elProps = super.deserialize(props) as RenderMaterialProps;\n const instance = props.row;\n elProps.paletteName = JsonUtils.asString(instance.paletteName);\n return elProps;\n }\n\n /**\n * RenderMaterialElement serializes 'paletteName'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: RenderMaterialProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n inst.paletteName = props.paletteName;\n return inst;\n }\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.renderMaterial);\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: RenderMaterialElementParams): RenderMaterialElement {\n let maps: RenderMaterialAssetMapsProps | undefined;\n const pbr_normal = params.normalMap?.scale;\n if (params.patternMap || params.normalMap) {\n // If both normal and pattern map are present, their texture mapping modes, angles, scales, etc are expected to match.\n type TexMap = Omit<TextureMapProps, \"TextureId\">;\n function choose<K extends keyof TexMap>(obj: TexMap, key: K): void {\n const pat = params.patternMap;\n if (pat && undefined !== pat[key])\n obj[key] = pat[key];\n else if (params.normalMap && undefined !== params.normalMap[key])\n obj[key] = params.normalMap[key];\n }\n\n const baseProps: TexMap = {};\n choose(baseProps, \"pattern_angle\");\n choose(baseProps, \"pattern_u_flip\");\n choose(baseProps, \"pattern_flip\");\n choose(baseProps, \"pattern_scale\");\n choose(baseProps, \"pattern_offset\");\n choose(baseProps, \"pattern_scalemode\");\n choose(baseProps, \"pattern_mapping\");\n choose(baseProps, \"pattern_weight\");\n choose(baseProps, \"pattern_useconstantlod\");\n choose(baseProps, \"pattern_constantlod_repetitions\");\n choose(baseProps, \"pattern_constantlod_offset\");\n choose(baseProps, \"pattern_constantlod_mindistanceclamp\");\n choose(baseProps, \"pattern_constantlod_maxdistanceclamp\");\n\n maps = {};\n if (params.patternMap)\n maps.Pattern = { ...params.patternMap, ...baseProps };\n\n if (params.normalMap) {\n maps.Normal = {\n ...params.normalMap,\n ...baseProps,\n };\n\n delete (maps.Normal as any).scale;\n }\n }\n\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 ? true : 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: maps,\n pbr_normal,\n },\n },\n },\n model: definitionModelId,\n isPrivate: false,\n };\n\n return new RenderMaterialElement(renderMaterialProps, iModelDb);\n }\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: RenderMaterialElementParams): Id64String {\n const renderMaterial = this.create(iModelDb, definitionModelId, materialName, params);\n return iModelDb.elements.insertElement(renderMaterial.toJSON());\n }\n\n /** @beta */\n protected static override onCloned(context: IModelElementCloneContext, sourceProps: ElementProps, targetProps: ElementProps) {\n super.onCloned(context, sourceProps, targetProps);\n for (const mapName in sourceProps.jsonProperties?.materialAssets?.renderMaterial?.Map ?? {}) {\n if (typeof mapName !== \"string\")\n continue;\n const sourceMap = sourceProps.jsonProperties.materialAssets.renderMaterial.Map[mapName];\n // sourceMap could be null/undefined, keep it the same in targetProps\n if (!sourceMap) {\n targetProps.jsonProperties.materialAssets.renderMaterial.Map[mapName] = sourceMap;\n continue;\n }\n if (!Id64.isValid(sourceMap.TextureId) || sourceMap.TextureId === undefined)\n continue;\n targetProps.jsonProperties.materialAssets.renderMaterial.Map[mapName].TextureId = context.findTargetElementId(sourceMap.TextureId ?? Id64.invalid);\n }\n }\n}\n\n/** @public */\nexport namespace RenderMaterialElement {\n /** Parameters used to construct a [[RenderMaterial]].\n * The persistent JSON representation - [RenderMaterialAssetProps]($common) - is quite verbose and unwieldy. This representation simplifies it somewhat.\n * @see [[RenderMaterialElement.create]] and [[RenderMaterialElement.insert]] to create a [[RenderMaterial]] from parameters of this type.\n * @deprecated in 3.6 - might be removed in next major version. Because it is not useful to use a `class` - just use [[RenderMaterialElementParams]] directly instead.\n */\n export class Params {\n /** A required palette name that categorizes this RenderMaterial */\n public paletteName: string;\n /** An optional description of this RenderMaterial */\n public description?: string;\n /** If defined, the color to use for surface fill or diffuse illumination, overriding the surface's own color. */\n public color?: RgbFactorProps;\n /** The color to use for specular illumination. Default: black. */\n public specularColor?: RgbFactorProps;\n /** The specular exponent describing the surface's shininess, in the range 0 through 128.\n * Default: 0.\n */\n public finish?: number;\n /** A transparency to be applied to the surface, ranging from 0 (fully opaque) to 1 (fully transparent).\n * If defined, then the material transparency overrides the transparency of whatever surface the material is applied to.\n * If undefined, the material has no effect on surface transparency.\n * Default: undefined.\n */\n public transmit?: number;\n /** The surface's diffuse reflectivity from 0.0 to 1.0. Default: 0.6. */\n public diffuse?: number;\n /** The surface's specular reflectivity from 0.0 to 1.0. Default: 0.0. */\n public specular?: number;\n /** Currently unused. */\n public reflect?: number;\n /** Currently unused. */\n public reflectColor?: number[];\n /** Specifies a texture image to map onto the surface, replacing or mixing with the surface's own color and transparency.\n * @note With the exception of `TextureId`, the [TextureMapProps]($common) of [[patternMap]] and [[normalMap]] are expected to be identical. If a property is defined in both\n * [[patternMap]]] and [[normalMap]], the value in [[patternMap]] takes precedence.\n */\n public patternMap?: TextureMapProps;\n /** Specifies a [normal map](https://en.wikipedia.org/wiki/Normal_mapping) to apply to the surface to simulate more surface detail than is present in the\n * surface's geometry.\n * @note With the exception of `TextureId`, the [TextureMapProps]($common) of [[patternMap]] and [[normalMap]] are expected to be identical. If a property is defined in both\n * [[patternMap]]] and [[normalMap]], the value in [[patternMap]] takes precedence.\n */\n public normalMap?: NormalMapProps & {\n /** A factor by which to multiply the components of the normal vectors read from the texture.\n * Default: 1.\n */\n scale?: number;\n };\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\n/** Parameters used to create a [[RenderMaterial]] element.\n * The persistent JSON representation - [RenderMaterialAssetProps]($common) - is quite verbose and unwieldy. This representation simplifies it somewhat.\n * @see [[RenderMaterialElement.create]] and [[RenderMaterialElement.insert]] to create a [[RenderMaterial]] from parameters of this type.\n * @public\n */\nexport interface RenderMaterialElementParams extends RenderMaterialElement.Params { // eslint-disable-line @typescript-eslint/no-deprecated, @typescript-eslint/no-empty-object-type\n}\n"]}
|
package/lib/cjs/Schema.d.ts
CHANGED
|
@@ -3,6 +3,31 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { SchemaKey } from "@itwin/ecschema-metadata";
|
|
5
5
|
/** Base class for all schema classes - see [working with schemas and elements in TypeScript]($docs/learning/backend/SchemasAndElementsInTypeScript.md).
|
|
6
|
+
*
|
|
7
|
+
* When subclassing from Schema, it is good practice to follow this pattern:
|
|
8
|
+
*
|
|
9
|
+
* ```typescript
|
|
10
|
+
* class MyCustomSchema extends Schema {
|
|
11
|
+
* public static override get schemaName(): string { return "MyCustomSchema"; }
|
|
12
|
+
* public static get classes(): typeof Entity[] {
|
|
13
|
+
* return [MyOwnECClass, AnotherECClass];
|
|
14
|
+
* }
|
|
15
|
+
* public static registerSchema() {
|
|
16
|
+
* if (this !== Schemas.getRegisteredSchema(this.schemaName)) {
|
|
17
|
+
* Schemas.unregisterSchema(this.schemaName);
|
|
18
|
+
* Schemas.registerSchema(this);
|
|
19
|
+
* for (const ecClass of this.classes) {
|
|
20
|
+
* ClassRegistry.register(ecClass, this);
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* public static unregisterSchema() {
|
|
26
|
+
* Schemas.unregisterSchema(this.schemaName);
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
6
31
|
* @public
|
|
7
32
|
*/
|
|
8
33
|
export declare class Schema {
|
package/lib/cjs/Schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../src/Schema.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAa,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEhE
|
|
1
|
+
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../src/Schema.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAa,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,MAAM;IACjB;;;;OAIG;IACH,WAAkB,UAAU,IAAI,MAAM,CAA4E;IAElH;;OAEG;IACH,WAAkB,SAAS,IAAI,SAAS,CAGvC;IAED;;;OAGG;IACH,WAAkB,uBAAuB,IAAI,OAAO,CAAkB;IAEtE;;;;;;OAMG;WACW,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IAQ3D;;;OAGG;IACH,SAAS;CACV;AAED;;;GAGG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoC;IAE7D,gBAAgB;IACT,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,MAAM,GAAG,SAAS;IAIzD,gBAAgB;IACT,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,MAAM,GAAG,IAAI;IAI3D,gBAAgB;IACT,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAI1C;;;OAGG;IACI,cAAc,CAAC,MAAM,EAAE,OAAO,MAAM;CAM5C;AAED;;GAEG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAmB;IACzD,OAAO;IAEP;;;OAGG;WACW,cAAc,CAAC,MAAM,EAAE,OAAO,MAAM;IAIlD;;;;OAIG;WACW,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAQ3D;;;OAGG;WACW,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,MAAM,GAAG,SAAS;CACjF"}
|
package/lib/cjs/Schema.js
CHANGED
|
@@ -13,6 +13,31 @@ const core_common_1 = require("@itwin/core-common");
|
|
|
13
13
|
const ClassRegistry_1 = require("./ClassRegistry");
|
|
14
14
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
15
15
|
/** Base class for all schema classes - see [working with schemas and elements in TypeScript]($docs/learning/backend/SchemasAndElementsInTypeScript.md).
|
|
16
|
+
*
|
|
17
|
+
* When subclassing from Schema, it is good practice to follow this pattern:
|
|
18
|
+
*
|
|
19
|
+
* ```typescript
|
|
20
|
+
* class MyCustomSchema extends Schema {
|
|
21
|
+
* public static override get schemaName(): string { return "MyCustomSchema"; }
|
|
22
|
+
* public static get classes(): typeof Entity[] {
|
|
23
|
+
* return [MyOwnECClass, AnotherECClass];
|
|
24
|
+
* }
|
|
25
|
+
* public static registerSchema() {
|
|
26
|
+
* if (this !== Schemas.getRegisteredSchema(this.schemaName)) {
|
|
27
|
+
* Schemas.unregisterSchema(this.schemaName);
|
|
28
|
+
* Schemas.registerSchema(this);
|
|
29
|
+
* for (const ecClass of this.classes) {
|
|
30
|
+
* ClassRegistry.register(ecClass, this);
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* public static unregisterSchema() {
|
|
36
|
+
* Schemas.unregisterSchema(this.schemaName);
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
16
41
|
* @public
|
|
17
42
|
*/
|
|
18
43
|
class Schema {
|
package/lib/cjs/Schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.js","sourceRoot":"","sources":["../../src/Schema.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAmD;AACnD,oDAAiD;AACjD,mDAAg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cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,mBAAmB,CAAC,UAAkB,IAA+B,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;;AA7BhJ,0BA8BC","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 Schema\n */\n\nimport { IModelStatus } from \"@itwin/core-bentley\";\nimport { IModelError } from \"@itwin/core-common\";\nimport { ClassRegistry } from \"./ClassRegistry\";\nimport { ECVersion, SchemaKey } from \"@itwin/ecschema-metadata\";\n\n/** Base class for all schema classes - see [working with schemas and elements in TypeScript]($docs/learning/backend/SchemasAndElementsInTypeScript.md).\n *\n * When subclassing from Schema, it is good practice to follow this pattern:\n *\n * ```typescript\n * class MyCustomSchema extends Schema {\n * public static override get schemaName(): string { return \"MyCustomSchema\"; }\n * public static get classes(): typeof Entity[] {\n * return [MyOwnECClass, AnotherECClass];\n * }\n * public static registerSchema() {\n * if (this !== Schemas.getRegisteredSchema(this.schemaName)) {\n * Schemas.unregisterSchema(this.schemaName);\n * Schemas.registerSchema(this);\n * for (const ecClass of this.classes) {\n * ClassRegistry.register(ecClass, this);\n * }\n * }\n * }\n *\n * public static unregisterSchema() {\n * Schemas.unregisterSchema(this.schemaName);\n * }\n * }\n * ```\n *\n * @public\n */\nexport class Schema {\n /** The name of the BIS schema handled by this Schema.\n * @note Every subclass of Schema ** MUST ** override this method to identify its BIS schema.\n * Failure to do so will ordinarily result in an error when the schema is registered, since there may only\n * be one JavaScript class for a given BIS schema (usually the errant schema will collide with its superclass.)\n */\n public static get schemaName(): string { throw new Error(`you must override static schemaName in ${this.name}`); }\n\n /** Unique identifier for this schema, typed variant of [[schemaName]].\n * @internal\n */\n public static get schemaKey(): SchemaKey {\n // We cannot cache this here because the schemaName may be overridden without this being overridden\n return new SchemaKey(this.schemaName, ECVersion.NO_VERSION); // backend cares little for versions right now, as only one version can exist in an imodel\n }\n\n /** if true, this Schema is a proxy for a missing Domain marked with the `BisCore.SchemaHasBehavior` customAttribute.\n * Classes generated for this Schema will disallow protected operations.\n * @internal\n */\n public static get missingRequiredBehavior(): boolean { return false; }\n\n /** Get a semver-compatible string from a padded version string.\n * works on unpadded version strings as well\n * if there is no write version, it will be added\n * @example Schema.toSemverString(\"1.02.03\") === \"1.2.3\"\n * @example Schema.toSemverString(\"1.01\") === \"1.0.1\" // write version was added\n * @beta\n */\n public static toSemverString(paddedVersion: string): string {\n const tuple = paddedVersion.split(\".\").map(Number);\n const noWriteVersion = tuple.length === 2;\n if (noWriteVersion)\n tuple.splice(1, 0, 0); // insert 0 before the second element\n return tuple.join(\".\");\n }\n\n /** Schemas may not be instantiated. The method is not private only because that precludes subclassing. It throws an\n * error if it is ever called.\n * @internal\n */\n protected constructor() { throw new Error(`cannot create an instance of a Schema ${this.constructor.name}`); }\n}\n\n/**\n * Holds a map of registered schemas.\n * @public\n */\nexport class SchemaMap {\n private readonly _schemas = new Map<string, typeof Schema>();\n\n /** @internal */\n public get(schemaName: string): typeof Schema | undefined {\n return this._schemas.get(schemaName.toLowerCase());\n }\n\n /** @internal */\n public set(schemaName: string, schema: typeof Schema): void {\n this._schemas.set(schemaName.toLowerCase(), schema);\n }\n\n /** @internal */\n public delete(schemaName: string): boolean {\n return this._schemas.delete(schemaName.toLowerCase());\n }\n\n /** Register a schema prior to using it.\n * @throws [[IModelError]] if a schema of the same name is already registered.\n * @public\n */\n public registerSchema(schema: typeof Schema) {\n const key = schema.schemaName.toLowerCase();\n if (this.get(key))\n throw new IModelError(IModelStatus.DuplicateName, `Schema \"${schema.schemaName}\" is already registered`);\n this.set(key, schema);\n }\n}\n\n/** Manages registered schemas\n * @public\n */\nexport class Schemas {\n private static readonly _globalSchemas = new SchemaMap();\n private constructor() { } // this is a singleton\n\n /** Register a schema prior to using it.\n * This method registers the schema globally, to register a schema within the scope of a single iModel, use `IModelDb.schemaMap`.\n * @throws [[IModelError]] if a schema of the same name is already registered.\n */\n public static registerSchema(schema: typeof Schema) {\n this._globalSchemas.registerSchema(schema);\n }\n\n /** Unregister a schema, by name, if one is already registered.\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\n * @param schemaName Name of the schema to unregister\n * @return true if the schema was unregistered\n */\n public static unregisterSchema(schemaName: string): boolean {\n const schema = this.getRegisteredSchema(schemaName);\n if (undefined !== schema)\n ClassRegistry.unregisterClassesFrom(schema);\n\n return this._globalSchemas.delete(schemaName.toLowerCase());\n }\n\n /** Look up a previously registered schema\n * @param schemaName The name of the schema\n * @returns the previously registered schema or undefined if not registered.\n */\n public static getRegisteredSchema(schemaName: string): typeof Schema | undefined { return this._globalSchemas.get(schemaName.toLowerCase()); }\n}\n"]}
|
|
@@ -39,6 +39,14 @@ export declare class EntityJsClassMap {
|
|
|
39
39
|
/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in "schema:class" format) and the JavaScript [[Entity]] class that implements it.
|
|
40
40
|
* Applications or modules that supply their own Entity subclasses should use [[registerModule]] or [[register]] at startup
|
|
41
41
|
* to establish their mappings.
|
|
42
|
+
*
|
|
43
|
+
* When creating custom Entity subclasses for registration, you should:
|
|
44
|
+
* - Override the `className` property to match your ECClass name:
|
|
45
|
+
* ```typescript
|
|
46
|
+
* public static override get className() { return "TestElement"; }
|
|
47
|
+
* ```
|
|
48
|
+
* - Do NOT override `schemaName` or `schema` - these will be wired up automatically during registration
|
|
49
|
+
*
|
|
42
50
|
* @public
|
|
43
51
|
*/
|
|
44
52
|
export declare class ClassRegistry {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassRegistry.d.ts","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],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ACW,cAAc,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,MAAM;IAQlE;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAc5B;;;;OAIG;WACW,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,MAAM,GAAG,SAAS;IAInF;;;;OAIG;WACW,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,MAAM;IAK9E;;;;;OAKG;WACW,eAAe,CAAC,aAAa,EAAE,MAAM;IAEnD;;;;OAIG;WACW,qBAAqB,CAAC,MAAM,EAAE,OAAO,MAAM;CAM1D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,SAAS,CAAqC;IACtD,OAAO,CAAC,cAAc,CAAiC;IAEvD,wCAAwC;IAEjC,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAKvD,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,cAAc,GAAG,SAAS;IAKrE,gCAAgC;IAEzB,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI;CAKlE"}
|
package/lib/esm/ClassRegistry.js
CHANGED
|
@@ -67,6 +67,14 @@ export class EntityJsClassMap {
|
|
|
67
67
|
/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in "schema:class" format) and the JavaScript [[Entity]] class that implements it.
|
|
68
68
|
* Applications or modules that supply their own Entity subclasses should use [[registerModule]] or [[register]] at startup
|
|
69
69
|
* to establish their mappings.
|
|
70
|
+
*
|
|
71
|
+
* When creating custom Entity subclasses for registration, you should:
|
|
72
|
+
* - Override the `className` property to match your ECClass name:
|
|
73
|
+
* ```typescript
|
|
74
|
+
* public static override get className() { return "TestElement"; }
|
|
75
|
+
* ```
|
|
76
|
+
* - Do NOT override `schemaName` or `schema` - these will be wired up automatically during registration
|
|
77
|
+
*
|
|
70
78
|
* @public
|
|
71
79
|
*/
|
|
72
80
|
export class ClassRegistry {
|