@itwin/core-frontend 5.9.0-dev.15 → 5.9.0-dev.17

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.
@@ -1 +1 @@
1
- {"version":3,"file":"PerModelCategoryVisibility.d.ts","sourceRoot":"","sources":["../../src/PerModelCategoryVisibility.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAkB,IAAI,EAAE,OAAO,EAAE,UAAU,EAAe,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;;;GAQG;AACH,yBAAiB,0BAA0B,CAAC;IAC1C,uEAAuE;IACvE,KAAY,QAAQ;QAClB,wIAAwI;QACxI,IAAI,IAAA;QACJ,gDAAgD;QAChD,IAAI,IAAA;QACJ,kDAAkD;QAClD,IAAI,IAAA;KACL;IAED,uFAAuF;IACvF,UAAiB,aAAa;QAC5B,2EAA2E;QAC3E,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;QAC7B,gFAAgF;QAChF,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;QAChC,mEAAmE;QACnE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;KAC3B;IAED;;OAEG;IACH,UAAiB,SAAS;QACxB,uFAAuF;QACvF,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,QAAQ,CAAC;QACnE,mFAAmF;QACnF,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;QAC/E;;WAEG;QACH,YAAY,CAAC,0BAA0B,EAAE,KAAK,EAAE,EAAE,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC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entley";
8
+ import { Id64 } from "@itwin/core-bentley";
9
9
  /** Per-model category visibility permits the visibility of categories within a [[Viewport]] displaying a [[SpatialViewState]] to be overridden in
10
10
  * the context of individual [[GeometricModelState]]s.
11
11
  * If a category's visibility is overridden for a given model, then elements belonging to that category within that model will be displayed or hidden regardless of the category's inclusion in the Viewport's [[CategorySelectorState]].
@@ -32,41 +32,77 @@ export var PerModelCategoryVisibility;
32
32
  }
33
33
  PerModelCategoryVisibility.createOverrides = createOverrides;
34
34
  })(PerModelCategoryVisibility || (PerModelCategoryVisibility = {}));
35
- class PerModelCategoryVisibilityOverride {
36
- modelId;
37
- categoryId;
38
- visible;
39
- constructor(modelId, categoryId, visible) {
40
- this.modelId = modelId;
41
- this.categoryId = categoryId;
42
- this.visible = visible;
43
- }
44
- reset(modelId, categoryId, visible) {
45
- this.modelId = modelId;
46
- this.categoryId = categoryId;
47
- this.visible = visible;
48
- }
49
- }
50
- function compareCategoryOverrides(lhs, rhs) {
51
- const cmp = compareStrings(lhs.modelId, rhs.modelId);
52
- return 0 === cmp ? compareStrings(lhs.categoryId, rhs.categoryId) : cmp;
53
- }
54
35
  /** The Viewport-specific implementation of PerModelCategoryVisibility.Overrides. */
55
- class PerModelCategoryVisibilityOverrides extends SortedArray {
56
- _scratch = new PerModelCategoryVisibilityOverride("0", "0", false);
36
+ class PerModelCategoryVisibilityOverrides {
37
+ _map = new Map();
38
+ /** Flat set of all override entries, providing O(1) iteration via [Symbol.iterator]. Kept in sync with `_map`. */
39
+ _set = new Set();
57
40
  _vp;
58
41
  constructor(vp) {
59
- super(compareCategoryOverrides);
60
42
  this._vp = vp;
61
43
  }
44
+ [Symbol.iterator]() {
45
+ return this._set[Symbol.iterator]();
46
+ }
62
47
  getOverride(modelId, categoryId) {
63
- this._scratch.reset(modelId, categoryId, false);
64
- const ovr = this.findEqual(this._scratch);
48
+ const ovr = this._map.get(modelId)?.get(categoryId);
65
49
  if (undefined !== ovr)
66
50
  return ovr.visible ? PerModelCategoryVisibility.Override.Show : PerModelCategoryVisibility.Override.Hide;
67
51
  else
68
52
  return PerModelCategoryVisibility.Override.None;
69
53
  }
54
+ getModelEntry({ modelId, override }) {
55
+ let modelEntry = this._map.get(modelId);
56
+ if (modelEntry) {
57
+ return modelEntry;
58
+ }
59
+ if (override === PerModelCategoryVisibility.Override.None) {
60
+ return undefined;
61
+ }
62
+ modelEntry = new Map();
63
+ this._map.set(modelId, modelEntry);
64
+ return modelEntry;
65
+ }
66
+ addOrRemoveOverrideEntry({ modelEntry, categoryId, modelId, override }) {
67
+ const overrideEntry = modelEntry.get(categoryId);
68
+ if (override === PerModelCategoryVisibility.Override.None) {
69
+ if (overrideEntry === undefined) {
70
+ return false;
71
+ }
72
+ this._set.delete(overrideEntry);
73
+ modelEntry.delete(categoryId);
74
+ return true;
75
+ }
76
+ const visible = override === PerModelCategoryVisibility.Override.Show;
77
+ if (overrideEntry === undefined) {
78
+ const ovr = { modelId, categoryId, visible };
79
+ modelEntry.set(categoryId, ovr);
80
+ this._set.add(ovr);
81
+ return true;
82
+ }
83
+ if (overrideEntry.visible !== visible) {
84
+ overrideEntry.visible = visible;
85
+ return true;
86
+ }
87
+ return false;
88
+ }
89
+ applyOverride(modelId, categoryIds, override, catIdsToLoad) {
90
+ const modelEntry = this.getModelEntry({ modelId, override });
91
+ let changed = false;
92
+ if (!modelEntry)
93
+ return changed;
94
+ for (const categoryId of categoryIds) {
95
+ if (this.addOrRemoveOverrideEntry({ modelEntry, categoryId, modelId, override })) {
96
+ changed = true;
97
+ if (catIdsToLoad && override !== PerModelCategoryVisibility.Override.None)
98
+ catIdsToLoad.push(categoryId);
99
+ }
100
+ }
101
+ if (modelEntry.size === 0) {
102
+ this._map.delete(modelId);
103
+ }
104
+ return changed;
105
+ }
70
106
  /**
71
107
  * set the overrides for multiple perModelCategoryVisibility props, loading categoryIds from the iModel if necessary.
72
108
  * @see [[PerModelCategoryVisibility]]
@@ -81,19 +117,11 @@ class PerModelCategoryVisibilityOverrides extends SortedArray {
81
117
  const catIdsToLoad = [];
82
118
  const iModelToUse = iModel ? iModel : this._vp.iModel;
83
119
  for (const override of perModelCategoryVisibility) {
84
- const modelId = override.modelId;
85
120
  // The caller may pass a single categoryId as a string, if we don't convert this to an array we will iterate
86
121
  // over each individual character of that string, which is not the desired behavior.
87
122
  const categoryIds = typeof override.categoryIds === "string" ? [override.categoryIds] : override.categoryIds;
88
- const visOverride = override.visOverride;
89
- for (const categoryId of categoryIds) {
90
- if (this.findAndUpdateOverrideInArray(modelId, categoryId, visOverride)) {
91
- anyChanged = true;
92
- if (PerModelCategoryVisibility.Override.None !== visOverride) {
93
- catIdsToLoad.push(categoryId);
94
- }
95
- }
96
- }
123
+ if (this.applyOverride(override.modelId, categoryIds, override.visOverride, catIdsToLoad))
124
+ anyChanged = true;
97
125
  }
98
126
  if (anyChanged) {
99
127
  this._vp.setViewedCategoriesPerModelChanged();
@@ -101,44 +129,17 @@ class PerModelCategoryVisibilityOverrides extends SortedArray {
101
129
  this._vp.subcategories.push(iModelToUse.subcategories, catIdsToLoad, () => this._vp.setViewedCategoriesPerModelChanged());
102
130
  }
103
131
  }
104
- return;
105
- }
106
- /** Find and update the override in the array of overrides. If override not found, adds it to the array.
107
- * If the array was changed, returns true. */
108
- findAndUpdateOverrideInArray(modelId, categoryId, override) {
109
- const ovr = this._scratch;
110
- ovr.reset(modelId, categoryId, false);
111
- let changed = false;
112
- const index = this.indexOf(ovr);
113
- if (-1 === index) {
114
- if (PerModelCategoryVisibility.Override.None !== override) {
115
- this.insert(new PerModelCategoryVisibilityOverride(modelId, categoryId, PerModelCategoryVisibility.Override.Show === override));
116
- changed = true;
117
- }
118
- }
119
- else {
120
- if (PerModelCategoryVisibility.Override.None === override) {
121
- this._array.splice(index, 1);
122
- changed = true;
123
- }
124
- else if (this._array[index].visible !== (PerModelCategoryVisibility.Override.Show === override)) {
125
- this._array[index].visible = (PerModelCategoryVisibility.Override.Show === override);
126
- changed = true;
127
- }
128
- }
129
- return changed;
130
132
  }
131
133
  setOverride(modelIds, categoryIds, override) {
134
+ const categoryIdIterable = Id64.iterable(categoryIds);
132
135
  let changed = false;
133
136
  for (const modelId of Id64.iterable(modelIds)) {
134
- for (const categoryId of Id64.iterable(categoryIds)) {
135
- if (this.findAndUpdateOverrideInArray(modelId, categoryId, override))
136
- changed = true;
137
- }
137
+ if (this.applyOverride(modelId, categoryIdIterable, override))
138
+ changed = true;
138
139
  }
139
140
  if (changed) {
140
141
  this._vp.setViewedCategoriesPerModelChanged();
141
- if (PerModelCategoryVisibility.Override.None !== override) {
142
+ if (override !== PerModelCategoryVisibility.Override.None) {
142
143
  // Ensure subcategories loaded.
143
144
  this._vp.subcategories.push(this._vp.iModel.subcategories, categoryIds, () => this._vp.setViewedCategoriesPerModelChanged());
144
145
  }
@@ -146,30 +147,32 @@ class PerModelCategoryVisibilityOverrides extends SortedArray {
146
147
  }
147
148
  clearOverrides(modelIds) {
148
149
  if (undefined === modelIds) {
149
- if (0 < this.length) {
150
- this.clear();
150
+ if (this._map.size > 0) {
151
+ this._map.clear();
152
+ this._set.clear();
151
153
  this._vp.setViewedCategoriesPerModelChanged();
152
154
  }
153
155
  return;
154
156
  }
155
- for (let i = 0; i < this.length;) {
156
- const ovr = this._array[i];
157
- let removed = false;
158
- for (const modelId of Id64.iterable(modelIds)) {
159
- if (modelId === ovr.modelId) {
160
- this._array.splice(i, 1);
161
- this._vp.setViewedCategoriesPerModelChanged();
162
- removed = true;
163
- break;
164
- }
157
+ let changed = false;
158
+ for (const modelId of Id64.iterable(modelIds)) {
159
+ const modelEntry = this._map.get(modelId);
160
+ if (!modelEntry) {
161
+ continue;
162
+ }
163
+ changed = true;
164
+ for (const overrideEntry of modelEntry.values()) {
165
+ this._set.delete(overrideEntry);
165
166
  }
166
- if (!removed)
167
- ++i;
167
+ this._map.delete(modelId);
168
+ }
169
+ if (changed) {
170
+ this._vp.setViewedCategoriesPerModelChanged();
168
171
  }
169
172
  }
170
173
  addOverrides(fs, ovrs) {
171
174
  const cache = this._vp.iModel.subcategories;
172
- for (const ovr of this._array) {
175
+ for (const ovr of this._set) {
173
176
  const subcats = cache.getSubCategories(ovr.categoryId);
174
177
  if (undefined === subcats)
175
178
  continue;
@@ -179,7 +182,6 @@ class PerModelCategoryVisibilityOverrides extends SortedArray {
179
182
  /* if (!this._vp.view.viewsModel(ovr.modelId))
180
183
  continue; */
181
184
  // ###TODO: Avoid recomputing upper and lower portions of modelId if modelId repeated.
182
- // (Array is sorted first by modelId).
183
185
  // Also avoid computing if no effective overrides.
184
186
  const modelLo = Id64.getLowerUint32(ovr.modelId);
185
187
  const modelHi = Id64.getUpperUint32(ovr.modelId);
@@ -1 +1 @@
1
- {"version":3,"file":"PerModelCategoryVisibility.js","sourceRoot":"","sources":["../../src/PerModelCategoryVisibility.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,IAAI,EAAuB,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAK7F;;;;;;;;GAQG;AACH,MAAM,KAAW,0BAA0B,CAyD1C;AAzDD,WAAiB,0BAA0B;IACzC,uEAAuE;IACvE,IAAY,QAOX;IAPD,WAAY,QAAQ;QAClB,wIAAwI;QACxI,uCAAI,CAAA;QACJ,gDAAgD;QAChD,uCAAI,CAAA;QACJ,kDAAkD;QAClD,uCAAI,CAAA;IACN,CAAC,EAPW,QAAQ,GAAR,mCAAQ,KAAR,mCAAQ,QAOnB;IA6CD,SAAgB,eAAe,CAAC,QAAkB;QAChD,OAAO,IAAI,mCAAmC,CAAC,QAAQ,CAAC,CAAC;IAC3D,CAAC;IAFe,0CAAe,kBAE9B,CAAA;AACH,CAAC,EAzDgB,0BAA0B,KAA1B,0BAA0B,QAyD1C;AAED,MAAM,kCAAkC;IAC/B,OAAO,CAAa;IACpB,UAAU,CAAa;IACvB,OAAO,CAAU;IAExB,YAAmB,OAAmB,EAAE,UAAsB,EAAE,OAAgB;QAC9E,IAAI,CAAC,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CAAC;gBACxD,IAAI,GAAG,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC;oBACxB,oEAAoE;oBACpE,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBACvC,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;wBACxB,KAAK,GAAG,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;wBAC7B,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;oBACpC,CAAC;oBAED,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF","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 Views\n */\n\nimport { compareStrings, Id64, Id64Arg, Id64String, SortedArray } from \"@itwin/core-bentley\";\nimport { IModelConnection } from \"./IModelConnection\";\nimport { FeatureSymbology } from \"./render/FeatureSymbology\";\nimport { Viewport } from \"./Viewport\";\n\n/** Per-model category visibility permits the visibility of categories within a [[Viewport]] displaying a [[SpatialViewState]] to be overridden in\n * the context of individual [[GeometricModelState]]s.\n * If a category's visibility is overridden for a given model, then elements belonging to that category within that model will be displayed or hidden regardless of the category's inclusion in the Viewport's [[CategorySelectorState]].\n * The override affects geometry on all subcategories belonging to the overridden category. That is, if the category is overridden to be visible, then geometry on all subcategories of the category\n * will be visible, regardless of any [SubCategoryOverride]($common)s applied by the view's [[DisplayStyleState]].\n * @see [[Viewport.perModelCategoryVisibility]] to define the per-model category visibility for a viewport.\n * @public\n * @extensions\n */\nexport namespace PerModelCategoryVisibility {\n /** Describes whether and how a category's visibility is overridden. */\n export enum Override {\n /** The category's visibility is not overridden; its visibility is wholly controlled by the [[Viewport]]'s [[CategorySelectorState]]. */\n None,\n /** The category is overridden to be visible. */\n Show,\n /** The category is overridden to be invisible. */\n Hide,\n }\n\n /** Describes one visibility override in a [[PerModelCategoryVisibility.Overrides]]. */\n export interface OverrideEntry {\n /** The Id of the [[GeometricModelState]] in which the override applies. */\n readonly modelId: Id64String;\n /** The Id of the [SpatialCategory]($backend) whose visibility is overridden. */\n readonly categoryId: Id64String;\n /** Whether the category is visible in the context of the model. */\n readonly visible: boolean;\n }\n\n /** Describes a set of per-model category visibility overrides. Changes to these overrides invoke the [[Viewport.onViewedCategoriesPerModelChanged]] event.\n * @see [[Viewport.perModelCategoryVisibility]].\n */\n export interface Overrides {\n /** Returns the override state of the specified category within the specified model. */\n getOverride(modelId: Id64String, categoryId: Id64String): Override;\n /** Changes the override state of one or more categories for one or more models. */\n setOverride(modelIds: Id64Arg, categoryIds: Id64Arg, override: Override): void;\n /** Changes multiple overrides, given an array of overrides *\n * @beta\n */\n setOverrides(perModelCategoryVisibility: Props[], iModel?: IModelConnection): Promise<void>;\n /** Removes all overrides for the specified models, or for all models if `modelIds` is undefined. */\n clearOverrides(modelIds?: Id64Arg): void;\n /** An iterator over all of the visibility overrides. */\n [Symbol.iterator]: () => Iterator<OverrideEntry>;\n /** Populate the symbology overrides based on the per-model category visibility. */\n addOverrides(fs: FeatureSymbology.Overrides, ovrs: Id64.Uint32Map<Id64.Uint32Set>): void;\n }\n\n /** Describes a set of [[PerModelCategoryVisibility.Overrides]].\n * @see [[PerModelCategoryVisibility.Overrides.setOverrides]].\n * @beta\n */\n export interface Props {\n /** The id of the model to which the overrides apply. */\n modelId: string;\n /** The ids of the categories whose visibility are to be overridden within the context of the model. */\n categoryIds: Iterable<Id64String>;\n /** The visibility to be applied to the specified categories. */\n visOverride: PerModelCategoryVisibility.Override;\n }\n\n export function createOverrides(viewport: Viewport): PerModelCategoryVisibility.Overrides {\n return new PerModelCategoryVisibilityOverrides(viewport);\n }\n}\n\nclass PerModelCategoryVisibilityOverride {\n public modelId: Id64String;\n public categoryId: Id64String;\n public visible: boolean;\n\n public constructor(modelId: Id64String, categoryId: Id64String, visible: boolean) {\n this.modelId = modelId;\n this.categoryId = categoryId;\n this.visible = visible;\n }\n\n public reset(modelId: Id64String, categoryId: Id64String, visible: boolean): void {\n this.modelId = modelId;\n this.categoryId = categoryId;\n this.visible = visible;\n }\n}\n\nfunction compareCategoryOverrides(lhs: PerModelCategoryVisibilityOverride, rhs: PerModelCategoryVisibilityOverride): number {\n const cmp = compareStrings(lhs.modelId, rhs.modelId);\n return 0 === cmp ? compareStrings(lhs.categoryId, rhs.categoryId) : cmp;\n}\n\n/** The Viewport-specific implementation of PerModelCategoryVisibility.Overrides. */\nclass PerModelCategoryVisibilityOverrides extends SortedArray<PerModelCategoryVisibilityOverride> implements PerModelCategoryVisibility.Overrides {\n private readonly _scratch = new PerModelCategoryVisibilityOverride(\"0\", \"0\", false);\n private readonly _vp: Viewport;\n\n public constructor(vp: Viewport) {\n super(compareCategoryOverrides);\n this._vp = vp;\n }\n\n public getOverride(modelId: Id64String, categoryId: Id64String): PerModelCategoryVisibility.Override {\n this._scratch.reset(modelId, categoryId, false);\n const ovr = this.findEqual(this._scratch);\n if (undefined !== ovr)\n return ovr.visible ? PerModelCategoryVisibility.Override.Show : PerModelCategoryVisibility.Override.Hide;\n else\n return PerModelCategoryVisibility.Override.None;\n }\n\n /**\n * set the overrides for multiple perModelCategoryVisibility props, loading categoryIds from the iModel if necessary.\n * @see [[PerModelCategoryVisibility]]\n * @param perModelCategoryVisibility array of model category visibility overrides @see [[PerModelCategoryVisibility.Props]]\n * @param iModel Optional param iModel. If no iModel is provided, then the iModel associated with the viewport (used to construct this class) is used.\n * This optional iModel param is useful for apps which may show multiple iModels at once. Passing in an iModel ensures that the subcategories cache for the provided iModel\n * is populated as opposed to the iModel associated with the viewport which may or may not be an empty iModel.\n * @returns a promise that resolves once the overrides have been applied.\n */\n public async setOverrides(perModelCategoryVisibility: PerModelCategoryVisibility.Props[], iModel?: IModelConnection): Promise<void> {\n let anyChanged = false;\n const catIdsToLoad: string[] = [];\n const iModelToUse = iModel ? iModel : this._vp.iModel;\n for (const override of perModelCategoryVisibility) {\n const modelId = override.modelId;\n // The caller may pass a single categoryId as a string, if we don't convert this to an array we will iterate\n // over each individual character of that string, which is not the desired behavior.\n const categoryIds = typeof override.categoryIds === \"string\" ? [override.categoryIds] : override.categoryIds;\n const visOverride = override.visOverride;\n for (const categoryId of categoryIds) {\n if (this.findAndUpdateOverrideInArray(modelId, categoryId, visOverride)) {\n anyChanged = true;\n if (PerModelCategoryVisibility.Override.None !== visOverride) {\n catIdsToLoad.push(categoryId);\n }\n }\n }\n }\n if (anyChanged) {\n this._vp.setViewedCategoriesPerModelChanged();\n if (catIdsToLoad.length !== 0) {\n this._vp.subcategories.push(iModelToUse.subcategories, catIdsToLoad, () => this._vp.setViewedCategoriesPerModelChanged());\n }\n }\n return;\n }\n\n /** Find and update the override in the array of overrides. If override not found, adds it to the array.\n * If the array was changed, returns true. */\n private findAndUpdateOverrideInArray(modelId: Id64String, categoryId: Id64String, override: PerModelCategoryVisibility.Override): boolean {\n const ovr = this._scratch;\n ovr.reset(modelId, categoryId, false);\n let changed = false;\n const index = this.indexOf(ovr);\n if (-1 === index) {\n if (PerModelCategoryVisibility.Override.None !== override) {\n this.insert(new PerModelCategoryVisibilityOverride(modelId, categoryId, PerModelCategoryVisibility.Override.Show === override));\n changed = true;\n }\n } else {\n if (PerModelCategoryVisibility.Override.None === override) {\n this._array.splice(index, 1);\n changed = true;\n } else if (this._array[index].visible !== (PerModelCategoryVisibility.Override.Show === override)) {\n this._array[index].visible = (PerModelCategoryVisibility.Override.Show === override);\n changed = true;\n }\n }\n return changed;\n }\n\n public setOverride(modelIds: Id64Arg, categoryIds: Id64Arg, override: PerModelCategoryVisibility.Override): void {\n let changed = false;\n for (const modelId of Id64.iterable(modelIds)) {\n for (const categoryId of Id64.iterable(categoryIds)) {\n if (this.findAndUpdateOverrideInArray(modelId, categoryId, override))\n changed = true;\n }\n }\n\n if (changed) {\n this._vp.setViewedCategoriesPerModelChanged();\n\n if (PerModelCategoryVisibility.Override.None !== override) {\n // Ensure subcategories loaded.\n this._vp.subcategories.push(this._vp.iModel.subcategories, categoryIds, () => this._vp.setViewedCategoriesPerModelChanged());\n }\n }\n }\n\n public clearOverrides(modelIds?: Id64Arg): void {\n if (undefined === modelIds) {\n if (0 < this.length) {\n this.clear();\n this._vp.setViewedCategoriesPerModelChanged();\n }\n\n return;\n }\n\n for (let i = 0; i < this.length;) {\n const ovr = this._array[i];\n let removed = false;\n for (const modelId of Id64.iterable(modelIds)) {\n if (modelId === ovr.modelId) {\n this._array.splice(i, 1);\n this._vp.setViewedCategoriesPerModelChanged();\n removed = true;\n break;\n }\n }\n\n if (!removed)\n ++i;\n }\n }\n\n public addOverrides(fs: FeatureSymbology.Overrides, ovrs: Id64.Uint32Map<Id64.Uint32Set>): void {\n const cache = this._vp.iModel.subcategories;\n\n for (const ovr of this._array) {\n const subcats = cache.getSubCategories(ovr.categoryId);\n if (undefined === subcats)\n continue;\n\n // It's pointless to override for models which aren't displayed...except if we do this, and then someone enables that model,\n // we would need to regenerate our symbology overrides in response. Preferably people wouldn't bother overriding models that\n // they don't want us to draw...\n /* if (!this._vp.view.viewsModel(ovr.modelId))\n continue; */\n\n // ###TODO: Avoid recomputing upper and lower portions of modelId if modelId repeated.\n // (Array is sorted first by modelId).\n // Also avoid computing if no effective overrides.\n const modelLo = Id64.getLowerUint32(ovr.modelId);\n const modelHi = Id64.getUpperUint32(ovr.modelId);\n\n for (const subcat of subcats) {\n const subcatLo = Id64.getLowerUint32(subcat);\n const subcatHi = Id64.getUpperUint32(subcat);\n const vis = fs.isSubCategoryVisible(subcatLo, subcatHi);\n if (vis !== ovr.visible) {\n // Only care if visibility differs from that defined for entire view\n let entry = ovrs.get(modelLo, modelHi);\n if (undefined === entry) {\n entry = new Id64.Uint32Set();\n ovrs.set(modelLo, modelHi, entry);\n }\n\n entry.add(subcatLo, subcat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,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF","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 Views\n */\n\nimport { Id64, Id64Arg, Id64String } from \"@itwin/core-bentley\";\nimport { IModelConnection } from \"./IModelConnection\";\nimport { FeatureSymbology } from \"./render/FeatureSymbology\";\nimport { Viewport } from \"./Viewport\";\n\n/** Per-model category visibility permits the visibility of categories within a [[Viewport]] displaying a [[SpatialViewState]] to be overridden in\n * the context of individual [[GeometricModelState]]s.\n * If a category's visibility is overridden for a given model, then elements belonging to that category within that model will be displayed or hidden regardless of the category's inclusion in the Viewport's [[CategorySelectorState]].\n * The override affects geometry on all subcategories belonging to the overridden category. That is, if the category is overridden to be visible, then geometry on all subcategories of the category\n * will be visible, regardless of any [SubCategoryOverride]($common)s applied by the view's [[DisplayStyleState]].\n * @see [[Viewport.perModelCategoryVisibility]] to define the per-model category visibility for a viewport.\n * @public\n * @extensions\n */\nexport namespace PerModelCategoryVisibility {\n /** Describes whether and how a category's visibility is overridden. */\n export enum Override {\n /** The category's visibility is not overridden; its visibility is wholly controlled by the [[Viewport]]'s [[CategorySelectorState]]. */\n None,\n /** The category is overridden to be visible. */\n Show,\n /** The category is overridden to be invisible. */\n Hide,\n }\n\n /** Describes one visibility override in a [[PerModelCategoryVisibility.Overrides]]. */\n export interface OverrideEntry {\n /** The Id of the [[GeometricModelState]] in which the override applies. */\n readonly modelId: Id64String;\n /** The Id of the [SpatialCategory]($backend) whose visibility is overridden. */\n readonly categoryId: Id64String;\n /** Whether the category is visible in the context of the model. */\n readonly visible: boolean;\n }\n\n /** Describes a set of per-model category visibility overrides. Changes to these overrides invoke the [[Viewport.onViewedCategoriesPerModelChanged]] event.\n * @see [[Viewport.perModelCategoryVisibility]].\n */\n export interface Overrides {\n /** Returns the override state of the specified category within the specified model. */\n getOverride(modelId: Id64String, categoryId: Id64String): Override;\n /** Changes the override state of one or more categories for one or more models. */\n setOverride(modelIds: Id64Arg, categoryIds: Id64Arg, override: Override): void;\n /** Changes multiple overrides, given an array of overrides *\n * @beta\n */\n setOverrides(perModelCategoryVisibility: Props[], iModel?: IModelConnection): Promise<void>;\n /** Removes all overrides for the specified models, or for all models if `modelIds` is undefined. */\n clearOverrides(modelIds?: Id64Arg): void;\n /** An iterator over all of the visibility overrides. */\n [Symbol.iterator]: () => Iterator<OverrideEntry>;\n /** Populate the symbology overrides based on the per-model category visibility. */\n addOverrides(fs: FeatureSymbology.Overrides, ovrs: Id64.Uint32Map<Id64.Uint32Set>): void;\n }\n\n /** Describes a set of [[PerModelCategoryVisibility.Overrides]].\n * @see [[PerModelCategoryVisibility.Overrides.setOverrides]].\n * @beta\n */\n export interface Props {\n /** The id of the model to which the overrides apply. */\n modelId: string;\n /** The ids of the categories whose visibility are to be overridden within the context of the model. */\n categoryIds: Iterable<Id64String>;\n /** The visibility to be applied to the specified categories. */\n visOverride: PerModelCategoryVisibility.Override;\n }\n\n export function createOverrides(viewport: Viewport): PerModelCategoryVisibility.Overrides {\n return new PerModelCategoryVisibilityOverrides(viewport);\n }\n}\ntype Writeable<T extends object> = { -readonly [P in keyof T]: T[P] };\ntype WriteableOverrideEntry = Writeable<PerModelCategoryVisibility.OverrideEntry>;\n\ntype ModelEntry = Map<Id64String, WriteableOverrideEntry>;\n\n/** The Viewport-specific implementation of PerModelCategoryVisibility.Overrides. */\nclass PerModelCategoryVisibilityOverrides implements PerModelCategoryVisibility.Overrides {\n private readonly _map = new Map<Id64String, ModelEntry>();\n /** Flat set of all override entries, providing O(1) iteration via [Symbol.iterator]. Kept in sync with `_map`. */\n private readonly _set = new Set<WriteableOverrideEntry>();\n private readonly _vp: Viewport;\n\n public constructor(vp: Viewport) {\n this._vp = vp;\n }\n\n\n public [Symbol.iterator](): Iterator<PerModelCategoryVisibility.OverrideEntry> {\n return this._set[Symbol.iterator]();\n }\n\n public getOverride(modelId: Id64String, categoryId: Id64String): PerModelCategoryVisibility.Override {\n const ovr = this._map.get(modelId)?.get(categoryId);\n if (undefined !== ovr)\n return ovr.visible ? PerModelCategoryVisibility.Override.Show : PerModelCategoryVisibility.Override.Hide;\n else\n return PerModelCategoryVisibility.Override.None;\n }\n\n private getModelEntry({ modelId, override }: { modelId: Id64String; override: PerModelCategoryVisibility.Override }): ModelEntry | undefined {\n let modelEntry = this._map.get(modelId);\n if (modelEntry) {\n return modelEntry;\n }\n if (override === PerModelCategoryVisibility.Override.None) {\n return undefined;\n }\n modelEntry = new Map<Id64String, WriteableOverrideEntry>();\n this._map.set(modelId, modelEntry);\n return modelEntry;\n }\n\n private addOrRemoveOverrideEntry({ modelEntry, categoryId, modelId, override }: { modelEntry: ModelEntry; categoryId: Id64String; modelId: Id64String; override: PerModelCategoryVisibility.Override }): boolean {\n const overrideEntry = modelEntry.get(categoryId);\n if (override === PerModelCategoryVisibility.Override.None) {\n if (overrideEntry === undefined) {\n return false;\n }\n\n this._set.delete(overrideEntry);\n modelEntry.delete(categoryId);\n return true;\n }\n const visible = override === PerModelCategoryVisibility.Override.Show;\n if (overrideEntry === undefined) {\n const ovr: WriteableOverrideEntry = { modelId, categoryId, visible };\n modelEntry.set(categoryId, ovr);\n this._set.add(ovr);\n return true;\n }\n if (overrideEntry.visible !== visible) {\n overrideEntry.visible = visible;\n return true;\n }\n return false;\n }\n\n private applyOverride(modelId: Id64String, categoryIds: Iterable<Id64String>, override: PerModelCategoryVisibility.Override, catIdsToLoad?: string[]): boolean {\n const modelEntry = this.getModelEntry({ modelId, override });\n let changed = false;\n if (!modelEntry)\n return changed;\n\n for (const categoryId of categoryIds) {\n if (this.addOrRemoveOverrideEntry({ modelEntry, categoryId, modelId, override })) {\n changed = true;\n if (catIdsToLoad && override !== PerModelCategoryVisibility.Override.None)\n catIdsToLoad.push(categoryId);\n }\n }\n if (modelEntry.size === 0) {\n this._map.delete(modelId);\n }\n return changed;\n }\n\n /**\n * set the overrides for multiple perModelCategoryVisibility props, loading categoryIds from the iModel if necessary.\n * @see [[PerModelCategoryVisibility]]\n * @param perModelCategoryVisibility array of model category visibility overrides @see [[PerModelCategoryVisibility.Props]]\n * @param iModel Optional param iModel. If no iModel is provided, then the iModel associated with the viewport (used to construct this class) is used.\n * This optional iModel param is useful for apps which may show multiple iModels at once. Passing in an iModel ensures that the subcategories cache for the provided iModel\n * is populated as opposed to the iModel associated with the viewport which may or may not be an empty iModel.\n * @returns a promise that resolves once the overrides have been applied.\n */\n public async setOverrides(perModelCategoryVisibility: PerModelCategoryVisibility.Props[], iModel?: IModelConnection): Promise<void> {\n let anyChanged = false;\n const catIdsToLoad: string[] = [];\n const iModelToUse = iModel ? iModel : this._vp.iModel;\n for (const override of perModelCategoryVisibility) {\n // The caller may pass a single categoryId as a string, if we don't convert this to an array we will iterate\n // over each individual character of that string, which is not the desired behavior.\n const categoryIds = typeof override.categoryIds === \"string\" ? [override.categoryIds] : override.categoryIds;\n if (this.applyOverride(override.modelId, categoryIds, override.visOverride, catIdsToLoad))\n anyChanged = true;\n }\n if (anyChanged) {\n this._vp.setViewedCategoriesPerModelChanged();\n if (catIdsToLoad.length !== 0) {\n this._vp.subcategories.push(iModelToUse.subcategories, catIdsToLoad, () => this._vp.setViewedCategoriesPerModelChanged());\n }\n }\n }\n\n public setOverride(modelIds: Id64Arg, categoryIds: Id64Arg, override: PerModelCategoryVisibility.Override): void {\n const categoryIdIterable = Id64.iterable(categoryIds);\n let changed = false;\n for (const modelId of Id64.iterable(modelIds)) {\n if (this.applyOverride(modelId, categoryIdIterable, override))\n changed = true;\n }\n\n if (changed) {\n this._vp.setViewedCategoriesPerModelChanged();\n\n if (override !== PerModelCategoryVisibility.Override.None) {\n // Ensure subcategories loaded.\n this._vp.subcategories.push(this._vp.iModel.subcategories, categoryIds, () => this._vp.setViewedCategoriesPerModelChanged());\n }\n }\n }\n\n public clearOverrides(modelIds?: Id64Arg): void {\n if (undefined === modelIds) {\n if (this._map.size > 0) {\n this._map.clear();\n this._set.clear();\n this._vp.setViewedCategoriesPerModelChanged();\n }\n return;\n }\n\n let changed = false;\n for (const modelId of Id64.iterable(modelIds)) {\n const modelEntry = this._map.get(modelId);\n if (!modelEntry) {\n continue;\n }\n changed = true;\n for (const overrideEntry of modelEntry.values()) {\n this._set.delete(overrideEntry);\n }\n this._map.delete(modelId);\n }\n if (changed) {\n this._vp.setViewedCategoriesPerModelChanged();\n }\n }\n\n public addOverrides(fs: FeatureSymbology.Overrides, ovrs: Id64.Uint32Map<Id64.Uint32Set>): void {\n const cache = this._vp.iModel.subcategories;\n\n for (const ovr of this._set) {\n const subcats = cache.getSubCategories(ovr.categoryId);\n if (undefined === subcats)\n continue;\n\n // It's pointless to override for models which aren't displayed...except if we do this, and then someone enables that model,\n // we would need to regenerate our symbology overrides in response. Preferably people wouldn't bother overriding models that\n // they don't want us to draw...\n /* if (!this._vp.view.viewsModel(ovr.modelId))\n continue; */\n\n // ###TODO: Avoid recomputing upper and lower portions of modelId if modelId repeated.\n // Also avoid computing if no effective overrides.\n const modelLo = Id64.getLowerUint32(ovr.modelId);\n const modelHi = Id64.getUpperUint32(ovr.modelId);\n\n for (const subcat of subcats) {\n const subcatLo = Id64.getLowerUint32(subcat);\n const subcatHi = Id64.getUpperUint32(subcat);\n const vis = fs.isSubCategoryVisible(subcatLo, subcatHi);\n if (vis !== ovr.visible) {\n // Only care if visibility differs from that defined for entire view\n let entry = ovrs.get(modelLo, modelHi);\n if (undefined === entry) {\n entry = new Id64.Uint32Set();\n ovrs.set(modelLo, modelHi, entry);\n }\n\n entry.add(subcatLo, subcatHi);\n }\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FrustumUniforms.d.ts","sourceRoot":"","sources":["../../../../../src/internal/render/webgl/FrustumUniforms.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAsB,QAAQ,EAAE,OAAO,EA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AG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,EAChE,GAAG,EAAE,GAAG,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,EAChE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAC3D,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAClB,MAAM,CAAC,CAAC;AACZ,CAAC;AAED,SAAS,OAAO,CAAC,IAAY,EAAE,KAAa,EAAE,MAAc,EAAE,GAAW,EAAE,IAAY,EAAE,GAAW,EAAE,MAAgB;IACpH,QAAQ,CAAC,eAAe,CACtB,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,GAAG,EACxE,GAAG,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,EAAE,GAAG,EACxE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAC1E,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EACnB,MAAM,CAAC,CAAC;AACZ,CAAC","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 WebGL\n */\n\nimport { expectDefined } from \"@itwin/core-bentley\";\nimport { InverseMatrixState, Matrix4d, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\nimport { Frustum, Npc } from \"@itwin/core-common\";\nimport { UniformHandle } from \"./UniformHandle\";\nimport { IModelFrameLifecycle } from \"./IModelFrameLifecycle\";\nimport { Matrix4 } from \"./Matrix\";\nimport { desync, sync } from \"./Sync\";\n\n/** @internal */\nexport const enum FrustumUniformType { // eslint-disable-line no-restricted-syntax\n TwoDee,\n Orthographic,\n Perspective,\n}\n\n/** @internal */\nexport const enum Plane { // eslint-disable-line no-restricted-syntax\n kTop,\n kBottom,\n kLeft,\n kRight,\n}\n\nconst enum FrustumData { // eslint-disable-line no-restricted-syntax\n kNear,\n kFar,\n kType,\n}\n\n/** Represents a Target's frustum for use in glsl as a pair of uniforms.\n * Do not modify fields of exposed objects directly. e.g., do not directly manipulate the projection or view matrices - use the appropriate APIs.\n * @internal\n */\nexport class FrustumUniforms {\n // CPU state. Do not modify - use APIs.\n public readonly planFrustum = new Frustum();\n private _planFraction = 0;\n private readonly _nearPlaneCenter = new Point3d();\n public readonly viewMatrix = Transform.createIdentity();\n public readonly projectionMatrix = Matrix4d.createIdentity();\n private readonly _worldUpVector = Vector3d.unitZ();\n private readonly _viewUpVector = Vector3d.unitZ();\n\n // GPU state\n private readonly _planeData: Float32Array = new Float32Array(4);\n private readonly _frustumData: Float32Array = new Float32Array(3);\n public readonly projectionMatrix32 = new Matrix4();\n private readonly _logZData = new Float32Array(2);\n private readonly _viewUpVector32 = new Float32Array(3);\n\n // SyncTarget\n public syncKey = 0;\n\n // Scratch variables\n private readonly _scratch = {\n point3d: new Point3d(),\n vec3d: new Vector3d(),\n viewX: new Vector3d(),\n viewY: new Vector3d(),\n viewZ: new Vector3d(),\n };\n\n public constructor() {\n }\n\n public bindProjectionMatrix(uniform: UniformHandle): void {\n if (!sync(this, uniform))\n uniform.setMatrix4(this.projectionMatrix32);\n }\n\n public bindUpVector(uniform: UniformHandle): void {\n if (!sync(this, uniform))\n uniform.setUniform3fv(this._viewUpVector32);\n }\n\n // uniform vec4 u_frustumPlanes; // { top, bottom, left, right }\n public get planes(): Float32Array { return this._planeData; }\n\n // uniform vec3 u_frustum; // { near, far, type }\n public get frustum(): Float32Array { return this._frustumData; }\n\n public get nearPlane(): number { return this._frustumData[FrustumData.kNear]; }\n public get farPlane(): number { return this._frustumData[FrustumData.kFar]; }\n public get type(): FrustumUniformType { return this.frustum[FrustumData.kType] as FrustumUniformType; }\n public get is2d(): boolean { return FrustumUniformType.TwoDee === this.type; }\n public get planFraction(): number { return this._planFraction; }\n\n // uniform vec2 u_logZ where x = 1/near and y = log(far/near)\n public get logZ(): Float32Array { return this._logZData; }\n\n public changeFrustum(newFrustum: Frustum, newFraction: number, is3d: boolean): void {\n if (newFraction === this._planFraction && is3d !== this.is2d && newFrustum.equals(this.planFrustum))\n return;\n\n desync(this);\n\n newFrustum.clone(this.planFrustum);\n\n const farLowerLeft = newFrustum.getCorner(Npc.LeftBottomRear);\n const farLowerRight = newFrustum.getCorner(Npc.RightBottomRear);\n const farUpperLeft = newFrustum.getCorner(Npc.LeftTopRear);\n const farUpperRight = newFrustum.getCorner(Npc.RightTopRear);\n const nearLowerLeft = newFrustum.getCorner(Npc.LeftBottomFront);\n const nearLowerRight = newFrustum.getCorner(Npc.RightBottomFront);\n const nearUpperLeft = newFrustum.getCorner(Npc.LeftTopFront);\n const nearUpperRight = newFrustum.getCorner(Npc.RightTopFront);\n\n const nearCenter = nearLowerLeft.interpolate(0.5, nearUpperRight, this._scratch.point3d);\n\n const viewX = normalizedDifference(nearLowerRight, nearLowerLeft, this._scratch.viewX);\n const viewY = normalizedDifference(nearUpperLeft, nearLowerLeft, this._scratch.viewY);\n const viewZ = expectDefined(viewX.crossProduct(viewY, this._scratch.viewZ).normalize());\n\n this._planFraction = newFraction;\n\n if (!is3d || newFraction > 0.999) { // ortho or 2d\n const halfWidth = Vector3d.createStartEnd(farLowerRight, farLowerLeft, this._scratch.vec3d).magnitude() * 0.5;\n const halfHeight = Vector3d.createStartEnd(farLowerRight, farUpperRight).magnitude() * 0.5;\n const depth = Vector3d.createStartEnd(farLowerLeft, nearLowerLeft, this._scratch.vec3d).magnitude();\n\n lookIn(nearCenter, viewX, viewY, viewZ, this.viewMatrix);\n ortho(-halfWidth, halfWidth, -halfHeight, halfHeight, 0, depth, this.projectionMatrix);\n\n this._nearPlaneCenter.setFrom(nearLowerLeft);\n this._nearPlaneCenter.interpolate(0.5, nearUpperRight, this._nearPlaneCenter);\n\n this.setPlanes(halfHeight, -halfHeight, -halfWidth, halfWidth);\n this.setFrustum(0, depth, is3d ? FrustumUniformType.Orthographic : FrustumUniformType.TwoDee);\n } else { // perspective\n const scale = 1.0 / (1.0 - newFraction);\n const zVec = Vector3d.createStartEnd(farLowerLeft, nearLowerLeft, this._scratch.vec3d);\n const cameraPosition = fromSumOf(farLowerLeft, zVec, scale, this._scratch.point3d);\n\n const frustumLeft = dotDifference(farLowerLeft, cameraPosition, viewX) * newFraction;\n const frustumRight = dotDifference(farLowerRight, cameraPosition, viewX) * newFraction;\n const frustumBottom = dotDifference(farLowerLeft, cameraPosition, viewY) * newFraction;\n const frustumTop = dotDifference(farUpperLeft, cameraPosition, viewY) * newFraction;\n const frustumFront = -dotDifference(nearLowerLeft, cameraPosition, viewZ);\n const frustumBack = -dotDifference(farLowerLeft, cameraPosition, viewZ);\n\n lookIn(cameraPosition, viewX, viewY, viewZ, this.viewMatrix);\n frustum(frustumLeft, frustumRight, frustumBottom, frustumTop, frustumFront, frustumBack, this.projectionMatrix);\n\n IModelFrameLifecycle.onChangeCameraView.raiseEvent({\n cameraPosition,\n viewX,\n viewY,\n viewZ,\n });\n IModelFrameLifecycle.onChangeCameraFrustum.raiseEvent({\n type: FrustumUniformType.Perspective,\n left: frustumLeft,\n right: frustumRight,\n bottom: frustumBottom,\n top: frustumTop,\n front: frustumFront,\n back: frustumBack,\n });\n\n this._nearPlaneCenter.setFrom(nearLowerLeft);\n this._nearPlaneCenter.interpolate(0.5, nearUpperRight, this._nearPlaneCenter);\n\n this.setPlanes(frustumTop, frustumBottom, frustumLeft, frustumRight);\n this.setFrustum(frustumFront, frustumBack, FrustumUniformType.Perspective);\n }\n\n this.viewMatrix.matrix.inverseState = InverseMatrixState.unknown;\n\n this.viewMatrix.matrix.multiplyVector(this._worldUpVector, this._viewUpVector);\n this._viewUpVector.normalizeInPlace();\n this._viewUpVector32[0] = this._viewUpVector.x;\n this._viewUpVector32[1] = this._viewUpVector.y;\n this._viewUpVector32[2] = this._viewUpVector.z;\n\n this.projectionMatrix32.initFromMatrix4d(this.projectionMatrix);\n }\n\n public changeProjectionMatrix(newMatrix: Matrix4d): void {\n desync(this);\n this.projectionMatrix.setFrom(newMatrix);\n this.projectionMatrix32.initFromMatrix4d(this.projectionMatrix);\n }\n\n protected setPlanes(top: number, bottom: number, left: number, right: number): void {\n this._planeData[Plane.kTop] = top;\n this._planeData[Plane.kBottom] = bottom;\n this._planeData[Plane.kLeft] = left;\n this._planeData[Plane.kRight] = right;\n }\n\n protected setFrustum(nearPlane: number, farPlane: number, type: FrustumUniformType): void {\n this._frustumData[FrustumData.kNear] = nearPlane;\n this._frustumData[FrustumData.kFar] = farPlane;\n this._frustumData[FrustumData.kType] = type as number;\n\n // If nearPlane is zero, we don't have a camera (or got very unlucky); in that case shader will compute linear depth.\n this._logZData[0] = 0 !== nearPlane ? 1 / nearPlane : 0;\n this._logZData[1] = 0 !== nearPlane ? Math.log(farPlane / nearPlane) : farPlane;\n }\n}\n\nfunction normalizedDifference(p0: Point3d, p1: Point3d, out?: Vector3d): Vector3d {\n const result = undefined !== out ? out : new Vector3d();\n result.x = p0.x - p1.x;\n result.y = p0.y - p1.y;\n result.z = p0.z - p1.z;\n result.normalizeInPlace();\n return result;\n}\n\n/** @internal */\nexport function fromSumOf(p: Point3d, v: Vector3d, scale: number, out?: Point3d) {\n const result = undefined !== out ? out : new Point3d();\n result.x = p.x + v.x * scale;\n result.y = p.y + v.y * scale;\n result.z = p.z + v.z * scale;\n return result;\n}\n\nfunction dotDifference(pt: Point3d, origin: Point3d, vec: Vector3d): number {\n return (pt.x - origin.x) * vec.x + (pt.y - origin.y) * vec.y + (pt.z - origin.z) * vec.z;\n}\n\nfunction lookIn(eye: Point3d, viewX: Vector3d, viewY: Vector3d, viewZ: Vector3d, result: Transform) {\n const rot = result.matrix.coffs;\n rot[0] = viewX.x;\n rot[1] = viewX.y;\n rot[2] = viewX.z;\n rot[3] = viewY.x;\n rot[4] = viewY.y;\n rot[5] = viewY.z;\n rot[6] = viewZ.x;\n rot[7] = viewZ.y;\n rot[8] = viewZ.z;\n\n result.origin.x = -viewX.dotProduct(eye);\n result.origin.y = -viewY.dotProduct(eye);\n result.origin.z = -viewZ.dotProduct(eye);\n}\n\nfunction ortho(left: number, right: number, bottom: number, top: number, near: number, far: number, result: Matrix4d) {\n Matrix4d.createRowValues(\n 2.0 / (right - left), 0.0, 0.0, -(right + left) / (right - left),\n 0.0, 2.0 / (top - bottom), 0.0, -(top + bottom) / (top - bottom),\n 0.0, 0.0, -2.0 / (far - near), -(far + near) / (far - near),\n 0.0, 0.0, 0.0, 1.0,\n result);\n}\n\nfunction frustum(left: number, right: number, bottom: number, top: number, near: number, far: number, result: Matrix4d) {\n Matrix4d.createRowValues(\n (2.0 * near) / (right - left), 0.0, (right + left) / (right - left), 0.0,\n 0.0, (2.0 * near) / (top - bottom), (top + bottom) / (top - bottom), 0.0,\n 0.0, 0.0, -(far + near) / (far - near), -(2.0 * far * near) / (far - near),\n 0.0, 0.0, -1.0, 0.0,\n result);\n}\n"]}
1
+ {"version":3,"file":"FrustumUniforms.js","sourceRoot":"","sources":["../../../../../src/internal/render/webgl/FrustumUniforms.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;A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AC;AAED,SAAS,OAAO,CAAC,IAAY,EAAE,KAAa,EAAE,MAAc,EAAE,GAAW,EAAE,IAAY,EAAE,GAAW,EAAE,MAAgB;IACpH,QAAQ,CAAC,eAAe,CACtB,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,GAAG,EACxE,GAAG,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,EAAE,GAAG,EACxE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAC1E,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EACnB,MAAM,CAAC,CAAC;AACZ,CAAC","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 WebGL\n */\n\nimport { expectDefined } from \"@itwin/core-bentley\";\nimport { InverseMatrixState, Matrix4d, Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\nimport { Frustum, Npc } from \"@itwin/core-common\";\nimport { UniformHandle } from \"./UniformHandle\";\nimport { IModelFrameLifecycle } from \"./IModelFrameLifecycle\";\nimport { Matrix4 } from \"./Matrix\";\nimport { desync, sync } from \"./Sync\";\n\n/** @internal */\nexport const enum FrustumUniformType { // eslint-disable-line no-restricted-syntax\n TwoDee,\n Orthographic,\n Perspective,\n}\n\n/** @internal */\nexport const enum Plane { // eslint-disable-line no-restricted-syntax\n kTop,\n kBottom,\n kLeft,\n kRight,\n}\n\nconst enum FrustumData { // eslint-disable-line no-restricted-syntax\n kNear,\n kFar,\n kType,\n}\n\n/** Represents a Target's frustum for use in glsl as a pair of uniforms.\n * Do not modify fields of exposed objects directly. e.g., do not directly manipulate the projection or view matrices - use the appropriate APIs.\n * @internal\n */\nexport class FrustumUniforms {\n // CPU state. Do not modify - use APIs.\n public readonly planFrustum = new Frustum();\n private _planFraction = 0;\n private readonly _nearPlaneCenter = new Point3d();\n public readonly viewMatrix = Transform.createIdentity();\n public readonly projectionMatrix = Matrix4d.createIdentity();\n private readonly _worldUpVector = Vector3d.unitZ();\n private readonly _viewUpVector = Vector3d.unitZ();\n\n // GPU state\n private readonly _planeData: Float32Array = new Float32Array(4);\n private readonly _frustumData: Float32Array = new Float32Array(3);\n public readonly projectionMatrix32 = new Matrix4();\n private readonly _logZData = new Float32Array(2);\n private readonly _viewUpVector32 = new Float32Array(3);\n\n // SyncTarget\n public syncKey = 0;\n\n // Scratch variables\n private readonly _scratch = {\n point3d: new Point3d(),\n vec3d: new Vector3d(),\n viewX: new Vector3d(),\n viewY: new Vector3d(),\n viewZ: new Vector3d(),\n };\n\n public constructor() {\n }\n\n public bindProjectionMatrix(uniform: UniformHandle): void {\n if (!sync(this, uniform))\n uniform.setMatrix4(this.projectionMatrix32);\n }\n\n public bindUpVector(uniform: UniformHandle): void {\n if (!sync(this, uniform))\n uniform.setUniform3fv(this._viewUpVector32);\n }\n\n // uniform vec4 u_frustumPlanes; // { top, bottom, left, right }\n public get planes(): Float32Array { return this._planeData; }\n\n // uniform vec3 u_frustum; // { near, far, type }\n public get frustum(): Float32Array { return this._frustumData; }\n\n public get nearPlane(): number { return this._frustumData[FrustumData.kNear]; }\n public get farPlane(): number { return this._frustumData[FrustumData.kFar]; }\n public get type(): FrustumUniformType { return this.frustum[FrustumData.kType]; }\n public get is2d(): boolean { return FrustumUniformType.TwoDee === this.type; }\n public get planFraction(): number { return this._planFraction; }\n\n // uniform vec2 u_logZ where x = 1/near and y = log(far/near)\n public get logZ(): Float32Array { return this._logZData; }\n\n public changeFrustum(newFrustum: Frustum, newFraction: number, is3d: boolean): void {\n if (newFraction === this._planFraction && is3d !== this.is2d && newFrustum.equals(this.planFrustum))\n return;\n\n desync(this);\n\n newFrustum.clone(this.planFrustum);\n\n const farLowerLeft = newFrustum.getCorner(Npc.LeftBottomRear);\n const farLowerRight = newFrustum.getCorner(Npc.RightBottomRear);\n const farUpperLeft = newFrustum.getCorner(Npc.LeftTopRear);\n const farUpperRight = newFrustum.getCorner(Npc.RightTopRear);\n const nearLowerLeft = newFrustum.getCorner(Npc.LeftBottomFront);\n const nearLowerRight = newFrustum.getCorner(Npc.RightBottomFront);\n const nearUpperLeft = newFrustum.getCorner(Npc.LeftTopFront);\n const nearUpperRight = newFrustum.getCorner(Npc.RightTopFront);\n\n const nearCenter = nearLowerLeft.interpolate(0.5, nearUpperRight, this._scratch.point3d);\n\n const viewX = normalizedDifference(nearLowerRight, nearLowerLeft, this._scratch.viewX);\n const viewY = normalizedDifference(nearUpperLeft, nearLowerLeft, this._scratch.viewY);\n const viewZ = expectDefined(viewX.crossProduct(viewY, this._scratch.viewZ).normalize());\n\n this._planFraction = newFraction;\n\n if (!is3d || newFraction > 0.999) { // ortho or 2d\n const halfWidth = Vector3d.createStartEnd(farLowerRight, farLowerLeft, this._scratch.vec3d).magnitude() * 0.5;\n const halfHeight = Vector3d.createStartEnd(farLowerRight, farUpperRight).magnitude() * 0.5;\n const depth = Vector3d.createStartEnd(farLowerLeft, nearLowerLeft, this._scratch.vec3d).magnitude();\n\n lookIn(nearCenter, viewX, viewY, viewZ, this.viewMatrix);\n ortho(-halfWidth, halfWidth, -halfHeight, halfHeight, 0, depth, this.projectionMatrix);\n\n this._nearPlaneCenter.setFrom(nearLowerLeft);\n this._nearPlaneCenter.interpolate(0.5, nearUpperRight, this._nearPlaneCenter);\n\n this.setPlanes(halfHeight, -halfHeight, -halfWidth, halfWidth);\n this.setFrustum(0, depth, is3d ? FrustumUniformType.Orthographic : FrustumUniformType.TwoDee);\n } else { // perspective\n const scale = 1.0 / (1.0 - newFraction);\n const zVec = Vector3d.createStartEnd(farLowerLeft, nearLowerLeft, this._scratch.vec3d);\n const cameraPosition = fromSumOf(farLowerLeft, zVec, scale, this._scratch.point3d);\n\n const frustumLeft = dotDifference(farLowerLeft, cameraPosition, viewX) * newFraction;\n const frustumRight = dotDifference(farLowerRight, cameraPosition, viewX) * newFraction;\n const frustumBottom = dotDifference(farLowerLeft, cameraPosition, viewY) * newFraction;\n const frustumTop = dotDifference(farUpperLeft, cameraPosition, viewY) * newFraction;\n const frustumFront = -dotDifference(nearLowerLeft, cameraPosition, viewZ);\n const frustumBack = -dotDifference(farLowerLeft, cameraPosition, viewZ);\n\n lookIn(cameraPosition, viewX, viewY, viewZ, this.viewMatrix);\n frustum(frustumLeft, frustumRight, frustumBottom, frustumTop, frustumFront, frustumBack, this.projectionMatrix);\n\n IModelFrameLifecycle.onChangeCameraView.raiseEvent({\n cameraPosition,\n viewX,\n viewY,\n viewZ,\n });\n IModelFrameLifecycle.onChangeCameraFrustum.raiseEvent({\n type: FrustumUniformType.Perspective,\n left: frustumLeft,\n right: frustumRight,\n bottom: frustumBottom,\n top: frustumTop,\n front: frustumFront,\n back: frustumBack,\n });\n\n this._nearPlaneCenter.setFrom(nearLowerLeft);\n this._nearPlaneCenter.interpolate(0.5, nearUpperRight, this._nearPlaneCenter);\n\n this.setPlanes(frustumTop, frustumBottom, frustumLeft, frustumRight);\n this.setFrustum(frustumFront, frustumBack, FrustumUniformType.Perspective);\n }\n\n this.viewMatrix.matrix.inverseState = InverseMatrixState.unknown;\n\n this.viewMatrix.matrix.multiplyVector(this._worldUpVector, this._viewUpVector);\n this._viewUpVector.normalizeInPlace();\n this._viewUpVector32[0] = this._viewUpVector.x;\n this._viewUpVector32[1] = this._viewUpVector.y;\n this._viewUpVector32[2] = this._viewUpVector.z;\n\n this.projectionMatrix32.initFromMatrix4d(this.projectionMatrix);\n }\n\n public changeProjectionMatrix(newMatrix: Matrix4d): void {\n desync(this);\n this.projectionMatrix.setFrom(newMatrix);\n this.projectionMatrix32.initFromMatrix4d(this.projectionMatrix);\n }\n\n protected setPlanes(top: number, bottom: number, left: number, right: number): void {\n this._planeData[Plane.kTop] = top;\n this._planeData[Plane.kBottom] = bottom;\n this._planeData[Plane.kLeft] = left;\n this._planeData[Plane.kRight] = right;\n }\n\n protected setFrustum(nearPlane: number, farPlane: number, type: FrustumUniformType): void {\n this._frustumData[FrustumData.kNear] = nearPlane;\n this._frustumData[FrustumData.kFar] = farPlane;\n this._frustumData[FrustumData.kType] = type;\n\n // If nearPlane is zero, we don't have a camera (or got very unlucky); in that case shader will compute linear depth.\n this._logZData[0] = 0 !== nearPlane ? 1 / nearPlane : 0;\n this._logZData[1] = 0 !== nearPlane ? Math.log(farPlane / nearPlane) : farPlane;\n }\n}\n\nfunction normalizedDifference(p0: Point3d, p1: Point3d, out?: Vector3d): Vector3d {\n const result = undefined !== out ? out : new Vector3d();\n result.x = p0.x - p1.x;\n result.y = p0.y - p1.y;\n result.z = p0.z - p1.z;\n result.normalizeInPlace();\n return result;\n}\n\n/** @internal */\nexport function fromSumOf(p: Point3d, v: Vector3d, scale: number, out?: Point3d) {\n const result = undefined !== out ? out : new Point3d();\n result.x = p.x + v.x * scale;\n result.y = p.y + v.y * scale;\n result.z = p.z + v.z * scale;\n return result;\n}\n\nfunction dotDifference(pt: Point3d, origin: Point3d, vec: Vector3d): number {\n return (pt.x - origin.x) * vec.x + (pt.y - origin.y) * vec.y + (pt.z - origin.z) * vec.z;\n}\n\nfunction lookIn(eye: Point3d, viewX: Vector3d, viewY: Vector3d, viewZ: Vector3d, result: Transform) {\n const rot = result.matrix.coffs;\n rot[0] = viewX.x;\n rot[1] = viewX.y;\n rot[2] = viewX.z;\n rot[3] = viewY.x;\n rot[4] = viewY.y;\n rot[5] = viewY.z;\n rot[6] = viewZ.x;\n rot[7] = viewZ.y;\n rot[8] = viewZ.z;\n\n result.origin.x = -viewX.dotProduct(eye);\n result.origin.y = -viewY.dotProduct(eye);\n result.origin.z = -viewZ.dotProduct(eye);\n}\n\nfunction ortho(left: number, right: number, bottom: number, top: number, near: number, far: number, result: Matrix4d) {\n Matrix4d.createRowValues(\n 2.0 / (right - left), 0.0, 0.0, -(right + left) / (right - left),\n 0.0, 2.0 / (top - bottom), 0.0, -(top + bottom) / (top - bottom),\n 0.0, 0.0, -2.0 / (far - near), -(far + near) / (far - near),\n 0.0, 0.0, 0.0, 1.0,\n result);\n}\n\nfunction frustum(left: number, right: number, bottom: number, top: number, near: number, far: number, result: Matrix4d) {\n Matrix4d.createRowValues(\n (2.0 * near) / (right - left), 0.0, (right + left) / (right - left), 0.0,\n 0.0, (2.0 * near) / (top - bottom), (top + bottom) / (top - bottom), 0.0,\n 0.0, 0.0, -(far + near) / (far - near), -(2.0 * far * near) / (far - near),\n 0.0, 0.0, -1.0, 0.0,\n result);\n}\n"]}