complex-visual.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. /**
  2. * Copyright (c) 2018-2023 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { ParamDefinition as PD } from '../../mol-util/param-definition';
  7. import { Visual, VisualContext } from '../visual';
  8. import { Bond, Structure, StructureElement } from '../../mol-model/structure';
  9. import { Geometry, GeometryUtils } from '../../mol-geo/geometry/geometry';
  10. import { LocationIterator } from '../../mol-geo/util/location-iterator';
  11. import { Theme } from '../../mol-theme/theme';
  12. import { createIdentityTransform } from '../../mol-geo/geometry/transform-data';
  13. import { createRenderObject, GraphicsRenderObject, RenderObjectValues } from '../../mol-gl/render-object';
  14. import { PickingId } from '../../mol-geo/geometry/picking';
  15. import { Loci, isEveryLoci, EmptyLoci } from '../../mol-model/loci';
  16. import { Interval } from '../../mol-data/int';
  17. import { LocationCallback, VisualUpdateState } from '../util';
  18. import { ColorTheme } from '../../mol-theme/color';
  19. import { ValueCell, deepEqual } from '../../mol-util';
  20. import { createSizes, SizeData } from '../../mol-geo/geometry/size-data';
  21. import { createColors } from '../../mol-geo/geometry/color-data';
  22. import { MarkerAction } from '../../mol-util/marker-action';
  23. import { Mat4 } from '../../mol-math/linear-algebra';
  24. import { Overpaint } from '../../mol-theme/overpaint';
  25. import { Transparency } from '../../mol-theme/transparency';
  26. import { Mesh } from '../../mol-geo/geometry/mesh/mesh';
  27. import { Cylinders } from '../../mol-geo/geometry/cylinders/cylinders';
  28. import { Lines } from '../../mol-geo/geometry/lines/lines';
  29. import { Text } from '../../mol-geo/geometry/text/text';
  30. import { SizeTheme } from '../../mol-theme/size';
  31. import { DirectVolume } from '../../mol-geo/geometry/direct-volume/direct-volume';
  32. import { createMarkers } from '../../mol-geo/geometry/marker-data';
  33. import { StructureParams, StructureMeshParams, StructureTextParams, StructureDirectVolumeParams, StructureLinesParams, StructureCylindersParams, StructureTextureMeshParams, StructureSpheresParams } from './params';
  34. import { Clipping } from '../../mol-theme/clipping';
  35. import { TextureMesh } from '../../mol-geo/geometry/texture-mesh/texture-mesh';
  36. import { WebGLContext } from '../../mol-gl/webgl/context';
  37. import { isPromiseLike } from '../../mol-util/type-helpers';
  38. import { Substance } from '../../mol-theme/substance';
  39. import { Spheres } from '../../mol-geo/geometry/spheres/spheres';
  40. export interface ComplexVisual<P extends StructureParams> extends Visual<Structure, P> { }
  41. function createComplexRenderObject<G extends Geometry>(structure: Structure, geometry: G, locationIt: LocationIterator, theme: Theme, props: PD.Values<Geometry.Params<G>>, materialId: number) {
  42. const { createValues, createRenderableState } = Geometry.getUtils(geometry);
  43. const transform = createIdentityTransform();
  44. const values = createValues(geometry, transform, locationIt, theme, props);
  45. const state = createRenderableState(props);
  46. return createRenderObject(geometry.kind, values, state, materialId);
  47. }
  48. interface ComplexVisualBuilder<P extends StructureParams, G extends Geometry> {
  49. defaultProps: PD.Values<P>
  50. createGeometry(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<P>, geometry?: G): Promise<G> | G
  51. createLocationIterator(structure: Structure): LocationIterator
  52. getLoci(pickingId: PickingId, structure: Structure, id: number): Loci
  53. eachLocation(loci: Loci, structure: Structure, apply: (interval: Interval) => boolean, isMarking: boolean): boolean,
  54. setUpdateState(state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme, newStructure: Structure, currentStructure: Structure): void
  55. mustRecreate?: (structure: Structure, props: PD.Values<P>) => boolean
  56. processValues?: (values: RenderObjectValues<G['kind']>, geometry: G, props: PD.Values<P>, theme: Theme, webgl?: WebGLContext) => void
  57. dispose?: (geometry: G) => void
  58. }
  59. interface ComplexVisualGeometryBuilder<P extends StructureParams, G extends Geometry> extends ComplexVisualBuilder<P, G> {
  60. geometryUtils: GeometryUtils<G>
  61. }
  62. export function ComplexVisual<G extends Geometry, P extends StructureParams & Geometry.Params<G>>(builder: ComplexVisualGeometryBuilder<P, G>, materialId: number): ComplexVisual<P> {
  63. const { defaultProps, createGeometry, createLocationIterator, getLoci, eachLocation, setUpdateState, mustRecreate, processValues, dispose } = builder;
  64. const { updateValues, updateBoundingSphere, updateRenderableState, createPositionIterator } = builder.geometryUtils;
  65. const updateState = VisualUpdateState.create();
  66. const previousMark: Visual.PreviousMark = { loci: EmptyLoci, action: MarkerAction.None, status: -1 };
  67. let renderObject: GraphicsRenderObject<G['kind']> | undefined;
  68. let newProps: PD.Values<P>;
  69. let newTheme: Theme;
  70. let newStructure: Structure;
  71. let currentProps: PD.Values<P> = Object.assign({}, defaultProps);
  72. let currentTheme: Theme = Theme.createEmpty();
  73. let currentStructure: Structure;
  74. let geometry: G;
  75. let geometryVersion = -1;
  76. let locationIt: LocationIterator;
  77. let positionIt: LocationIterator;
  78. function prepareUpdate(theme: Theme, props: Partial<PD.Values<P>>, structure: Structure) {
  79. if (!structure && !currentStructure) {
  80. throw new Error('missing structure');
  81. }
  82. newProps = Object.assign({}, currentProps, props);
  83. newTheme = theme;
  84. newStructure = structure;
  85. VisualUpdateState.reset(updateState);
  86. if (!renderObject || !currentStructure) {
  87. updateState.createNew = true;
  88. updateState.createGeometry = true;
  89. return;
  90. }
  91. setUpdateState(updateState, newProps, currentProps, newTheme, currentTheme, newStructure, currentStructure);
  92. if (!Structure.areEquivalent(newStructure, currentStructure)) {
  93. updateState.createGeometry = true;
  94. }
  95. if (!Structure.areHierarchiesEqual(newStructure, currentStructure)) {
  96. updateState.updateTransform = true;
  97. updateState.createGeometry = true;
  98. }
  99. if (!ColorTheme.areEqual(theme.color, currentTheme.color)) {
  100. updateState.updateColor = true;
  101. }
  102. if (!deepEqual(newProps.unitKinds, currentProps.unitKinds)) {
  103. updateState.createGeometry = true;
  104. }
  105. if (currentStructure.child !== newStructure.child) {
  106. // console.log('new child');
  107. updateState.createGeometry = true;
  108. }
  109. if (newProps.instanceGranularity !== currentProps.instanceGranularity) {
  110. updateState.updateTransform = true;
  111. }
  112. if (updateState.updateSize && !('uSize' in renderObject.values)) {
  113. updateState.createGeometry = true;
  114. }
  115. if (updateState.createGeometry) {
  116. updateState.updateColor = true;
  117. updateState.updateSize = true;
  118. }
  119. }
  120. function update(newGeometry?: G) {
  121. if (updateState.createNew) {
  122. locationIt = createLocationIterator(newStructure);
  123. if (newGeometry) {
  124. renderObject = createComplexRenderObject(newStructure, newGeometry, locationIt, newTheme, newProps, materialId);
  125. positionIt = createPositionIterator(newGeometry, renderObject.values);
  126. } else {
  127. throw new Error('expected geometry to be given');
  128. }
  129. } else {
  130. if (!renderObject) {
  131. throw new Error('expected renderObject to be available');
  132. }
  133. if (updateState.updateTransform) {
  134. // console.log('update transform')
  135. locationIt = createLocationIterator(newStructure);
  136. const { instanceCount, groupCount } = locationIt;
  137. if (newProps.instanceGranularity) {
  138. createMarkers(instanceCount, 'instance', renderObject.values);
  139. } else {
  140. createMarkers(instanceCount * groupCount, 'groupInstance', renderObject.values);
  141. }
  142. }
  143. if (updateState.createGeometry) {
  144. if (newGeometry) {
  145. ValueCell.updateIfChanged(renderObject.values.drawCount, Geometry.getDrawCount(newGeometry));
  146. ValueCell.updateIfChanged(renderObject.values.uVertexCount, Geometry.getVertexCount(newGeometry));
  147. ValueCell.updateIfChanged(renderObject.values.uGroupCount, Geometry.getGroupCount(newGeometry));
  148. } else {
  149. throw new Error('expected geometry to be given');
  150. }
  151. }
  152. if (updateState.updateTransform || updateState.createGeometry) {
  153. updateBoundingSphere(renderObject.values, newGeometry || geometry);
  154. positionIt = createPositionIterator(geometry, renderObject.values);
  155. }
  156. if (updateState.updateSize) {
  157. // not all geometries have size data, so check here
  158. if ('uSize' in renderObject.values) {
  159. createSizes(locationIt, newTheme.size, renderObject.values as SizeData);
  160. }
  161. }
  162. if (updateState.updateColor) {
  163. createColors(locationIt, positionIt, newTheme.color, renderObject.values);
  164. }
  165. updateValues(renderObject.values, newProps);
  166. updateRenderableState(renderObject.state, newProps);
  167. }
  168. currentProps = newProps;
  169. currentTheme = newTheme;
  170. currentStructure = newStructure;
  171. if (newGeometry) {
  172. geometry = newGeometry;
  173. geometryVersion += 1;
  174. }
  175. }
  176. function lociIsSuperset(loci: Loci) {
  177. if (isEveryLoci(loci)) return true;
  178. if (Structure.isLoci(loci) && Structure.areRootsEquivalent(loci.structure, currentStructure)) return true;
  179. if (StructureElement.Loci.is(loci) && Structure.areRootsEquivalent(loci.structure, currentStructure)) {
  180. if (StructureElement.Loci.isWholeStructure(loci)) return true;
  181. }
  182. return false;
  183. }
  184. function eachInstance(loci: Loci, structure: Structure, apply: (interval: Interval) => boolean) {
  185. let changed = false;
  186. if (!StructureElement.Loci.is(loci) && !Bond.isLoci(loci)) return false;
  187. if (!Structure.areEquivalent(loci.structure, structure)) return false;
  188. if (apply(Interval.ofSingleton(0))) changed = true;
  189. return changed;
  190. }
  191. function lociApply(loci: Loci, apply: (interval: Interval) => boolean, isMarking: boolean) {
  192. if (lociIsSuperset(loci)) {
  193. if (currentProps.instanceGranularity) {
  194. return apply(Interval.ofBounds(0, locationIt.instanceCount));
  195. } else {
  196. return apply(Interval.ofBounds(0, locationIt.groupCount * locationIt.instanceCount));
  197. }
  198. } else {
  199. if (currentProps.instanceGranularity) {
  200. return eachInstance(loci, currentStructure, apply);
  201. } else {
  202. return eachLocation(loci, currentStructure, apply, isMarking);
  203. }
  204. }
  205. }
  206. function finalize(ctx: VisualContext) {
  207. if (renderObject) {
  208. processValues?.(renderObject.values, geometry, currentProps, currentTheme, ctx.webgl);
  209. }
  210. }
  211. return {
  212. get groupCount() { return locationIt ? locationIt.count : 0; },
  213. get renderObject() { return locationIt && locationIt.count ? renderObject : undefined; },
  214. get geometryVersion() { return geometryVersion; },
  215. createOrUpdate(ctx: VisualContext, theme: Theme, props: Partial<PD.Values<P>> = {}, structure?: Structure) {
  216. prepareUpdate(theme, props, structure || currentStructure);
  217. if (updateState.createGeometry) {
  218. const newGeometry = createGeometry(ctx, newStructure, newTheme, newProps, geometry);
  219. if (isPromiseLike(newGeometry)) {
  220. return newGeometry.then(g => {
  221. update(g);
  222. finalize(ctx);
  223. });
  224. }
  225. update(newGeometry);
  226. } else {
  227. update();
  228. }
  229. finalize(ctx);
  230. },
  231. getLoci(pickingId: PickingId) {
  232. return renderObject ? getLoci(pickingId, currentStructure, renderObject.id) : EmptyLoci;
  233. },
  234. eachLocation(cb: LocationCallback) {
  235. locationIt.reset();
  236. while (locationIt.hasNext) {
  237. const { location, isSecondary } = locationIt.move();
  238. cb(location, isSecondary);
  239. }
  240. },
  241. mark(loci: Loci, action: MarkerAction) {
  242. return Visual.mark(renderObject, loci, action, lociApply, previousMark);
  243. },
  244. setVisibility(visible: boolean) {
  245. Visual.setVisibility(renderObject, visible);
  246. },
  247. setAlphaFactor(alphaFactor: number) {
  248. Visual.setAlphaFactor(renderObject, alphaFactor);
  249. },
  250. setPickable(pickable: boolean) {
  251. Visual.setPickable(renderObject, pickable);
  252. },
  253. setColorOnly(colorOnly: boolean) {
  254. Visual.setColorOnly(renderObject, colorOnly);
  255. },
  256. setTransform(matrix?: Mat4, instanceMatrices?: Float32Array | null) {
  257. Visual.setTransform(renderObject, matrix, instanceMatrices);
  258. },
  259. setOverpaint(overpaint: Overpaint, webgl?: WebGLContext) {
  260. const smoothing = { geometry, props: currentProps, webgl };
  261. Visual.setOverpaint(renderObject, overpaint, lociApply, true, smoothing);
  262. },
  263. setTransparency(transparency: Transparency, webgl?: WebGLContext) {
  264. const smoothing = { geometry, props: currentProps, webgl };
  265. Visual.setTransparency(renderObject, transparency, lociApply, true, smoothing);
  266. },
  267. setSubstance(substance: Substance, webgl?: WebGLContext) {
  268. const smoothing = { geometry, props: currentProps, webgl };
  269. Visual.setSubstance(renderObject, substance, lociApply, true, smoothing);
  270. },
  271. setClipping(clipping: Clipping) {
  272. Visual.setClipping(renderObject, clipping, lociApply, true);
  273. },
  274. setThemeStrength(strength: { overpaint: number, transparency: number, substance: number }) {
  275. Visual.setThemeStrength(renderObject, strength);
  276. },
  277. destroy() {
  278. dispose?.(geometry);
  279. if (renderObject) {
  280. renderObject.state.disposed = true;
  281. renderObject = undefined;
  282. }
  283. },
  284. mustRecreate
  285. };
  286. }
  287. // mesh
  288. export const ComplexMeshParams = { ...StructureMeshParams, ...StructureParams };
  289. export type ComplexMeshParams = typeof ComplexMeshParams
  290. export interface ComplexMeshVisualBuilder<P extends ComplexMeshParams> extends ComplexVisualBuilder<P, Mesh> { }
  291. export function ComplexMeshVisual<P extends ComplexMeshParams>(builder: ComplexMeshVisualBuilder<P>, materialId: number): ComplexVisual<P> {
  292. return ComplexVisual<Mesh, P>({
  293. ...builder,
  294. setUpdateState: (state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme, newStructure: Structure, currentStructure: Structure) => {
  295. builder.setUpdateState(state, newProps, currentProps, newTheme, currentTheme, newStructure, currentStructure);
  296. if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.createGeometry = true;
  297. },
  298. geometryUtils: Mesh.Utils
  299. }, materialId);
  300. }
  301. // spheres
  302. export const ComplexSpheresParams = { ...StructureSpheresParams, ...StructureParams };
  303. export type ComplexSpheresParams = typeof ComplexSpheresParams
  304. export interface ComplexSpheresVisualBuilder<P extends ComplexSpheresParams> extends ComplexVisualBuilder<P, Spheres> { }
  305. export function ComplexSpheresVisual<P extends ComplexSpheresParams>(builder: ComplexSpheresVisualBuilder<P>, materialId: number): ComplexVisual<P> {
  306. return ComplexVisual<Spheres, P>({
  307. ...builder,
  308. setUpdateState: (state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme, newStructure: Structure, currentStructure: Structure) => {
  309. builder.setUpdateState(state, newProps, currentProps, newTheme, currentTheme, newStructure, currentStructure);
  310. if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.updateSize = true;
  311. },
  312. geometryUtils: Spheres.Utils
  313. }, materialId);
  314. }
  315. // cylinders
  316. export const ComplexCylindersParams = { ...StructureCylindersParams, ...StructureParams };
  317. export type ComplexCylindersParams = typeof ComplexCylindersParams
  318. export interface ComplexCylindersVisualBuilder<P extends ComplexCylindersParams> extends ComplexVisualBuilder<P, Cylinders> { }
  319. export function ComplexCylindersVisual<P extends ComplexCylindersParams>(builder: ComplexCylindersVisualBuilder<P>, materialId: number): ComplexVisual<P> {
  320. return ComplexVisual<Cylinders, P>({
  321. ...builder,
  322. setUpdateState: (state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme, newStructure: Structure, currentStructure: Structure) => {
  323. builder.setUpdateState(state, newProps, currentProps, newTheme, currentTheme, newStructure, currentStructure);
  324. if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.updateSize = true;
  325. },
  326. geometryUtils: Cylinders.Utils
  327. }, materialId);
  328. }
  329. // lines
  330. export const ComplexLinesParams = { ...StructureLinesParams, ...StructureParams };
  331. export type ComplexLinesParams = typeof ComplexLinesParams
  332. export interface ComplexLinesVisualBuilder<P extends ComplexLinesParams> extends ComplexVisualBuilder<P, Lines> { }
  333. export function ComplexLinesVisual<P extends ComplexLinesParams>(builder: ComplexLinesVisualBuilder<P>, materialId: number): ComplexVisual<P> {
  334. return ComplexVisual<Lines, P>({
  335. ...builder,
  336. setUpdateState: (state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme, newStructure: Structure, currentStructure: Structure) => {
  337. builder.setUpdateState(state, newProps, currentProps, newTheme, currentTheme, newStructure, currentStructure);
  338. if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.updateSize = true;
  339. },
  340. geometryUtils: Lines.Utils
  341. }, materialId);
  342. }
  343. // text
  344. export const ComplexTextParams = { ...StructureTextParams, ...StructureParams };
  345. export type ComplexTextParams = typeof ComplexTextParams
  346. export interface ComplexTextVisualBuilder<P extends ComplexTextParams> extends ComplexVisualBuilder<P, Text> { }
  347. export function ComplexTextVisual<P extends ComplexTextParams>(builder: ComplexTextVisualBuilder<P>, materialId: number): ComplexVisual<P> {
  348. return ComplexVisual<Text, P>({
  349. ...builder,
  350. setUpdateState: (state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme, newStructure: Structure, currentStructure: Structure) => {
  351. builder.setUpdateState(state, newProps, currentProps, newTheme, currentTheme, newStructure, currentStructure);
  352. if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.updateSize = true;
  353. if (newProps.background !== currentProps.background) state.createGeometry = true;
  354. if (newProps.backgroundMargin !== currentProps.backgroundMargin) state.createGeometry = true;
  355. if (newProps.tether !== currentProps.tether) state.createGeometry = true;
  356. if (newProps.tetherLength !== currentProps.tetherLength) state.createGeometry = true;
  357. if (newProps.tetherBaseWidth !== currentProps.tetherBaseWidth) state.createGeometry = true;
  358. if (newProps.attachment !== currentProps.attachment) state.createGeometry = true;
  359. if (newProps.fontFamily !== currentProps.fontFamily) state.createGeometry = true;
  360. if (newProps.fontQuality !== currentProps.fontQuality) state.createGeometry = true;
  361. if (newProps.fontStyle !== currentProps.fontStyle) state.createGeometry = true;
  362. if (newProps.fontVariant !== currentProps.fontVariant) state.createGeometry = true;
  363. if (newProps.fontWeight !== currentProps.fontWeight) state.createGeometry = true;
  364. },
  365. geometryUtils: Text.Utils
  366. }, materialId);
  367. }
  368. // direct-volume
  369. export const ComplexDirectVolumeParams = { ...StructureDirectVolumeParams, ...StructureParams };
  370. export type ComplexDirectVolumeParams = typeof ComplexDirectVolumeParams
  371. export interface ComplexDirectVolumeVisualBuilder<P extends ComplexDirectVolumeParams> extends ComplexVisualBuilder<P, DirectVolume> { }
  372. export function ComplexDirectVolumeVisual<P extends ComplexDirectVolumeParams>(builder: ComplexDirectVolumeVisualBuilder<P>, materialId: number): ComplexVisual<P> {
  373. return ComplexVisual<DirectVolume, P>({
  374. ...builder,
  375. setUpdateState: (state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme, newStructure: Structure, currentStructure: Structure) => {
  376. builder.setUpdateState(state, newProps, currentProps, newTheme, currentTheme, newStructure, currentStructure);
  377. if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.createGeometry = true;
  378. },
  379. geometryUtils: DirectVolume.Utils
  380. }, materialId);
  381. }
  382. // texture-mesh
  383. export const ComplexTextureMeshParams = { ...StructureTextureMeshParams, ...StructureParams };
  384. export type ComplexTextureMeshParams = typeof ComplexTextureMeshParams
  385. export interface ComplexTextureMeshVisualBuilder<P extends ComplexTextureMeshParams> extends ComplexVisualBuilder<P, TextureMesh> { }
  386. export function ComplexTextureMeshVisual<P extends ComplexTextureMeshParams>(builder: ComplexTextureMeshVisualBuilder<P>, materialId: number): ComplexVisual<P> {
  387. return ComplexVisual<TextureMesh, P>({
  388. ...builder,
  389. setUpdateState: (state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme, newStructure: Structure, currentStructure: Structure) => {
  390. builder.setUpdateState(state, newProps, currentProps, newTheme, currentTheme, newStructure, currentStructure);
  391. if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.createGeometry = true;
  392. },
  393. geometryUtils: TextureMesh.Utils
  394. }, materialId);
  395. }