gaussian-surface-mesh.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. /**
  2. * Copyright (c) 2018-2022 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 { UnitsMeshParams, UnitsTextureMeshParams, UnitsVisual, UnitsMeshVisual, UnitsTextureMeshVisual } from '../units-visual';
  8. import { GaussianDensityParams, computeUnitGaussianDensity, computeUnitGaussianDensityTexture2d, GaussianDensityProps, computeStructureGaussianDensity, computeStructureGaussianDensityTexture2d } from './util/gaussian';
  9. import { VisualContext } from '../../visual';
  10. import { Unit, Structure } from '../../../mol-model/structure';
  11. import { Theme } from '../../../mol-theme/theme';
  12. import { Mesh } from '../../../mol-geo/geometry/mesh/mesh';
  13. import { computeMarchingCubesMesh } from '../../../mol-geo/util/marching-cubes/algorithm';
  14. import { ElementIterator, getElementLoci, eachElement, getSerialElementLoci, eachSerialElement } from './util/element';
  15. import { VisualUpdateState } from '../../util';
  16. import { TextureMesh } from '../../../mol-geo/geometry/texture-mesh/texture-mesh';
  17. import { extractIsosurface } from '../../../mol-gl/compute/marching-cubes/isosurface';
  18. import { Sphere3D } from '../../../mol-math/geometry';
  19. import { ComplexVisual, ComplexMeshParams, ComplexMeshVisual, ComplexTextureMeshVisual, ComplexTextureMeshParams } from '../complex-visual';
  20. import { getVolumeSliceInfo, StructureGroup } from './util/common';
  21. import { WebGLContext } from '../../../mol-gl/webgl/context';
  22. import { MeshValues } from '../../../mol-gl/renderable/mesh';
  23. import { TextureMeshValues } from '../../../mol-gl/renderable/texture-mesh';
  24. import { Texture } from '../../../mol-gl/webgl/texture';
  25. import { applyMeshColorSmoothing } from '../../../mol-geo/geometry/mesh/color-smoothing';
  26. import { applyTextureMeshColorSmoothing } from '../../../mol-geo/geometry/texture-mesh/color-smoothing';
  27. import { ColorSmoothingParams, getColorSmoothingProps } from '../../../mol-geo/geometry/base';
  28. import { Vec3 } from '../../../mol-math/linear-algebra';
  29. const SharedParams = {
  30. ...GaussianDensityParams,
  31. ...ColorSmoothingParams,
  32. ignoreHydrogens: PD.Boolean(false),
  33. tryUseGpu: PD.Boolean(true),
  34. includeParent: PD.Boolean(false, { isHidden: true }),
  35. };
  36. type SharedParams = typeof SharedParams
  37. export const GaussianSurfaceMeshParams = {
  38. ...UnitsMeshParams,
  39. ...UnitsTextureMeshParams,
  40. ...SharedParams,
  41. };
  42. export type GaussianSurfaceMeshParams = typeof GaussianSurfaceMeshParams
  43. export const StructureGaussianSurfaceMeshParams = {
  44. ...ComplexMeshParams,
  45. ...ComplexTextureMeshParams,
  46. ...SharedParams,
  47. };
  48. export type StructureGaussianSurfaceMeshParams = typeof StructureGaussianSurfaceMeshParams
  49. function gpuSupport(webgl: WebGLContext) {
  50. return webgl.extensions.colorBufferFloat && webgl.extensions.textureFloat && webgl.extensions.blendMinMax && webgl.extensions.drawBuffers;
  51. }
  52. function suitableForGpu(structure: Structure, props: PD.Values<SharedParams>, webgl: WebGLContext) {
  53. // lower resolutions are about as fast on CPU vs integrated GPU,
  54. // very low resolutions have artifacts when calculated on GPU
  55. if (props.resolution > 1) return false;
  56. // the GPU is much more memory contraint, especially true for integrated GPUs,
  57. // being conservative here still allows for small and medium sized assemblies
  58. const d = webgl.maxTextureSize / 3;
  59. const { areaCells, maxAreaCells } = getVolumeSliceInfo(structure.boundary.box, props.resolution, d * d);
  60. return areaCells < maxAreaCells;
  61. }
  62. export function GaussianSurfaceVisual(materialId: number, structure: Structure, props: PD.Values<GaussianSurfaceMeshParams>, webgl?: WebGLContext) {
  63. if (props.tryUseGpu && webgl && gpuSupport(webgl) && suitableForGpu(structure, props, webgl)) {
  64. return GaussianSurfaceTextureMeshVisual(materialId);
  65. }
  66. return GaussianSurfaceMeshVisual(materialId);
  67. }
  68. export function StructureGaussianSurfaceVisual(materialId: number, structure: Structure, props: PD.Values<StructureGaussianSurfaceMeshParams>, webgl?: WebGLContext) {
  69. if (props.tryUseGpu && webgl && gpuSupport(webgl) && suitableForGpu(structure, props, webgl)) {
  70. return StructureGaussianSurfaceTextureMeshVisual(materialId);
  71. }
  72. return StructureGaussianSurfaceMeshVisual(materialId);
  73. }
  74. type GaussianSurfaceMeta = {
  75. resolution?: number
  76. colorTexture?: Texture
  77. }
  78. //
  79. async function createGaussianSurfaceMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: GaussianDensityProps, mesh?: Mesh): Promise<Mesh> {
  80. const { smoothness } = props;
  81. const { transform, field, idField, radiusFactor, resolution, maxRadius } = await computeUnitGaussianDensity(structure, unit, theme.size, props).runInContext(ctx.runtime);
  82. const params = {
  83. isoLevel: Math.exp(-smoothness) / radiusFactor,
  84. scalarField: field,
  85. idField
  86. };
  87. const surface = await computeMarchingCubesMesh(params, mesh).runAsChild(ctx.runtime);
  88. (surface.meta.resolution as GaussianSurfaceMeta['resolution']) = resolution;
  89. Mesh.transform(surface, transform);
  90. if (ctx.webgl && !ctx.webgl.isWebGL2) Mesh.uniformTriangleGroup(surface);
  91. const sphere = Sphere3D.expand(Sphere3D(), unit.boundary.sphere, maxRadius);
  92. surface.setBoundingSphere(sphere);
  93. return surface;
  94. }
  95. export function GaussianSurfaceMeshVisual(materialId: number): UnitsVisual<GaussianSurfaceMeshParams> {
  96. return UnitsMeshVisual<GaussianSurfaceMeshParams>({
  97. defaultProps: PD.getDefaultValues(GaussianSurfaceMeshParams),
  98. createGeometry: createGaussianSurfaceMesh,
  99. createLocationIterator: ElementIterator.fromGroup,
  100. getLoci: getElementLoci,
  101. eachLocation: eachElement,
  102. setUpdateState: (state: VisualUpdateState, newProps: PD.Values<GaussianSurfaceMeshParams>, currentProps: PD.Values<GaussianSurfaceMeshParams>) => {
  103. if (newProps.resolution !== currentProps.resolution) state.createGeometry = true;
  104. if (newProps.radiusOffset !== currentProps.radiusOffset) state.createGeometry = true;
  105. if (newProps.smoothness !== currentProps.smoothness) state.createGeometry = true;
  106. if (newProps.ignoreHydrogens !== currentProps.ignoreHydrogens) state.createGeometry = true;
  107. if (newProps.traceOnly !== currentProps.traceOnly) state.createGeometry = true;
  108. if (newProps.includeParent !== currentProps.includeParent) state.createGeometry = true;
  109. if (newProps.smoothColors.name !== currentProps.smoothColors.name) {
  110. state.updateColor = true;
  111. } else if (newProps.smoothColors.name === 'on' && currentProps.smoothColors.name === 'on') {
  112. if (newProps.smoothColors.params.resolutionFactor !== currentProps.smoothColors.params.resolutionFactor) state.updateColor = true;
  113. if (newProps.smoothColors.params.sampleStride !== currentProps.smoothColors.params.sampleStride) state.updateColor = true;
  114. }
  115. },
  116. mustRecreate: (structureGroup: StructureGroup, props: PD.Values<GaussianSurfaceMeshParams>, webgl?: WebGLContext) => {
  117. return props.tryUseGpu && !!webgl && suitableForGpu(structureGroup.structure, props, webgl);
  118. },
  119. processValues: (values: MeshValues, geometry: Mesh, props: PD.Values<GaussianSurfaceMeshParams>, theme: Theme, webgl?: WebGLContext) => {
  120. const { resolution, colorTexture } = geometry.meta as GaussianSurfaceMeta;
  121. const csp = getColorSmoothingProps(props.smoothColors, theme.color.preferSmoothing, resolution);
  122. if (csp) {
  123. applyMeshColorSmoothing(values, csp.resolution, csp.stride, webgl, colorTexture);
  124. (geometry.meta.colorTexture as GaussianSurfaceMeta['colorTexture']) = values.tColorGrid.ref.value;
  125. }
  126. },
  127. dispose: (geometry: Mesh) => {
  128. (geometry.meta as GaussianSurfaceMeta).colorTexture?.destroy();
  129. }
  130. }, materialId);
  131. }
  132. //
  133. async function createStructureGaussianSurfaceMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: GaussianDensityProps, mesh?: Mesh): Promise<Mesh> {
  134. const { smoothness } = props;
  135. const { transform, field, idField, radiusFactor, resolution, maxRadius } = await computeStructureGaussianDensity(structure, theme.size, props).runInContext(ctx.runtime);
  136. const params = {
  137. isoLevel: Math.exp(-smoothness) / radiusFactor,
  138. scalarField: field,
  139. idField
  140. };
  141. const surface = await computeMarchingCubesMesh(params, mesh).runAsChild(ctx.runtime);
  142. (surface.meta.resolution as GaussianSurfaceMeta['resolution']) = resolution;
  143. Mesh.transform(surface, transform);
  144. if (ctx.webgl && !ctx.webgl.isWebGL2) Mesh.uniformTriangleGroup(surface);
  145. const sphere = Sphere3D.expand(Sphere3D(), structure.boundary.sphere, maxRadius);
  146. surface.setBoundingSphere(sphere);
  147. return surface;
  148. }
  149. export function StructureGaussianSurfaceMeshVisual(materialId: number): ComplexVisual<StructureGaussianSurfaceMeshParams> {
  150. return ComplexMeshVisual<StructureGaussianSurfaceMeshParams>({
  151. defaultProps: PD.getDefaultValues(StructureGaussianSurfaceMeshParams),
  152. createGeometry: createStructureGaussianSurfaceMesh,
  153. createLocationIterator: ElementIterator.fromStructure,
  154. getLoci: getSerialElementLoci,
  155. eachLocation: eachSerialElement,
  156. setUpdateState: (state: VisualUpdateState, newProps: PD.Values<GaussianSurfaceMeshParams>, currentProps: PD.Values<GaussianSurfaceMeshParams>) => {
  157. if (newProps.resolution !== currentProps.resolution) state.createGeometry = true;
  158. if (newProps.radiusOffset !== currentProps.radiusOffset) state.createGeometry = true;
  159. if (newProps.smoothness !== currentProps.smoothness) state.createGeometry = true;
  160. if (newProps.ignoreHydrogens !== currentProps.ignoreHydrogens) state.createGeometry = true;
  161. if (newProps.traceOnly !== currentProps.traceOnly) state.createGeometry = true;
  162. if (newProps.smoothColors.name !== currentProps.smoothColors.name) {
  163. state.updateColor = true;
  164. } else if (newProps.smoothColors.name === 'on' && currentProps.smoothColors.name === 'on') {
  165. if (newProps.smoothColors.params.resolutionFactor !== currentProps.smoothColors.params.resolutionFactor) state.updateColor = true;
  166. if (newProps.smoothColors.params.sampleStride !== currentProps.smoothColors.params.sampleStride) state.updateColor = true;
  167. }
  168. },
  169. mustRecreate: (structure: Structure, props: PD.Values<StructureGaussianSurfaceMeshParams>, webgl?: WebGLContext) => {
  170. return props.tryUseGpu && !!webgl && suitableForGpu(structure, props, webgl);
  171. },
  172. processValues: (values: MeshValues, geometry: Mesh, props: PD.Values<GaussianSurfaceMeshParams>, theme: Theme, webgl?: WebGLContext) => {
  173. const { resolution, colorTexture } = geometry.meta as GaussianSurfaceMeta;
  174. const csp = getColorSmoothingProps(props.smoothColors, theme.color.preferSmoothing, resolution);
  175. if (csp) {
  176. applyMeshColorSmoothing(values, csp.resolution, csp.stride, webgl, colorTexture);
  177. (geometry.meta.colorTexture as GaussianSurfaceMeta['colorTexture']) = values.tColorGrid.ref.value;
  178. }
  179. },
  180. dispose: (geometry: Mesh) => {
  181. (geometry.meta as GaussianSurfaceMeta).colorTexture?.destroy();
  182. }
  183. }, materialId);
  184. }
  185. //
  186. const GaussianSurfaceName = 'gaussian-surface';
  187. async function createGaussianSurfaceTextureMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: GaussianDensityProps, textureMesh?: TextureMesh): Promise<TextureMesh> {
  188. if (!ctx.webgl) throw new Error('webgl context required to create gaussian surface texture-mesh');
  189. const { namedTextures, resources, extensions: { colorBufferFloat, textureFloat, colorBufferHalfFloat, textureHalfFloat } } = ctx.webgl;
  190. if (!namedTextures[GaussianSurfaceName]) {
  191. namedTextures[GaussianSurfaceName] = colorBufferHalfFloat && textureHalfFloat
  192. ? resources.texture('image-float16', 'rgba', 'fp16', 'linear')
  193. : colorBufferFloat && textureFloat
  194. ? resources.texture('image-float32', 'rgba', 'float', 'linear')
  195. : resources.texture('image-uint8', 'rgba', 'ubyte', 'linear');
  196. }
  197. // console.time('computeUnitGaussianDensityTexture2d');
  198. const densityTextureData = await computeUnitGaussianDensityTexture2d(structure, unit, theme.size, true, props, ctx.webgl, namedTextures[GaussianSurfaceName]).runInContext(ctx.runtime);
  199. // console.log(densityTextureData);
  200. // console.log('vertexGroupTexture', readTexture(ctx.webgl, densityTextureData.texture));
  201. // ctx.webgl.waitForGpuCommandsCompleteSync();
  202. // console.timeEnd('computeUnitGaussianDensityTexture2d');
  203. const isoLevel = Math.exp(-props.smoothness) / densityTextureData.radiusFactor;
  204. const axisOrder = Vec3.create(0, 1, 2);
  205. const buffer = textureMesh?.doubleBuffer.get();
  206. const gv = extractIsosurface(ctx.webgl, densityTextureData.texture, densityTextureData.gridDim, densityTextureData.gridTexDim, densityTextureData.gridTexScale, densityTextureData.transform, isoLevel, false, true, axisOrder, buffer?.vertex, buffer?.group, buffer?.normal);
  207. const boundingSphere = Sphere3D.expand(Sphere3D(), unit.boundary.sphere, densityTextureData.maxRadius);
  208. const surface = TextureMesh.create(gv.vertexCount, 1, gv.vertexTexture, gv.groupTexture, gv.normalTexture, boundingSphere, textureMesh);
  209. (surface.meta as GaussianSurfaceMeta).resolution = densityTextureData.resolution;
  210. return surface;
  211. }
  212. export function GaussianSurfaceTextureMeshVisual(materialId: number): UnitsVisual<GaussianSurfaceMeshParams> {
  213. return UnitsTextureMeshVisual<GaussianSurfaceMeshParams>({
  214. defaultProps: PD.getDefaultValues(GaussianSurfaceMeshParams),
  215. createGeometry: createGaussianSurfaceTextureMesh,
  216. createLocationIterator: ElementIterator.fromGroup,
  217. getLoci: getElementLoci,
  218. eachLocation: eachElement,
  219. setUpdateState: (state: VisualUpdateState, newProps: PD.Values<GaussianSurfaceMeshParams>, currentProps: PD.Values<GaussianSurfaceMeshParams>) => {
  220. if (newProps.resolution !== currentProps.resolution) state.createGeometry = true;
  221. if (newProps.radiusOffset !== currentProps.radiusOffset) state.createGeometry = true;
  222. if (newProps.smoothness !== currentProps.smoothness) state.createGeometry = true;
  223. if (newProps.ignoreHydrogens !== currentProps.ignoreHydrogens) state.createGeometry = true;
  224. if (newProps.traceOnly !== currentProps.traceOnly) state.createGeometry = true;
  225. if (newProps.includeParent !== currentProps.includeParent) state.createGeometry = true;
  226. if (newProps.smoothColors.name !== currentProps.smoothColors.name) {
  227. state.updateColor = true;
  228. } else if (newProps.smoothColors.name === 'on' && currentProps.smoothColors.name === 'on') {
  229. if (newProps.smoothColors.params.resolutionFactor !== currentProps.smoothColors.params.resolutionFactor) state.updateColor = true;
  230. if (newProps.smoothColors.params.sampleStride !== currentProps.smoothColors.params.sampleStride) state.updateColor = true;
  231. }
  232. },
  233. mustRecreate: (structureGroup: StructureGroup, props: PD.Values<GaussianSurfaceMeshParams>, webgl?: WebGLContext) => {
  234. return !props.tryUseGpu || !webgl || !suitableForGpu(structureGroup.structure, props, webgl);
  235. },
  236. processValues: (values: TextureMeshValues, geometry: TextureMesh, props: PD.Values<GaussianSurfaceMeshParams>, theme: Theme, webgl?: WebGLContext) => {
  237. const { resolution, colorTexture } = geometry.meta as GaussianSurfaceMeta;
  238. const csp = getColorSmoothingProps(props.smoothColors, theme.color.preferSmoothing, resolution);
  239. if (csp && webgl) {
  240. applyTextureMeshColorSmoothing(values, csp.resolution, csp.stride, webgl, colorTexture);
  241. (geometry.meta as GaussianSurfaceMeta).colorTexture = values.tColorGrid.ref.value;
  242. }
  243. },
  244. dispose: (geometry: TextureMesh) => {
  245. geometry.vertexTexture.ref.value.destroy();
  246. geometry.groupTexture.ref.value.destroy();
  247. geometry.normalTexture.ref.value.destroy();
  248. geometry.doubleBuffer.destroy();
  249. (geometry.meta as GaussianSurfaceMeta).colorTexture?.destroy();
  250. }
  251. }, materialId);
  252. }
  253. //
  254. async function createStructureGaussianSurfaceTextureMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: GaussianDensityProps, textureMesh?: TextureMesh): Promise<TextureMesh> {
  255. if (!ctx.webgl) throw new Error('webgl context required to create structure gaussian surface texture-mesh');
  256. const { namedTextures, resources, extensions: { colorBufferFloat, textureFloat, colorBufferHalfFloat, textureHalfFloat } } = ctx.webgl;
  257. if (!namedTextures[GaussianSurfaceName]) {
  258. namedTextures[GaussianSurfaceName] = colorBufferHalfFloat && textureHalfFloat
  259. ? resources.texture('image-float16', 'rgba', 'fp16', 'linear')
  260. : colorBufferFloat && textureFloat
  261. ? resources.texture('image-float32', 'rgba', 'float', 'linear')
  262. : resources.texture('image-uint8', 'rgba', 'ubyte', 'linear');
  263. }
  264. // console.time('computeUnitGaussianDensityTexture2d');
  265. const densityTextureData = await computeStructureGaussianDensityTexture2d(structure, theme.size, true, props, ctx.webgl, namedTextures[GaussianSurfaceName]).runInContext(ctx.runtime);
  266. // console.log(densityTextureData);
  267. // console.log('vertexGroupTexture', readTexture(ctx.webgl, densityTextureData.texture));
  268. // ctx.webgl.waitForGpuCommandsCompleteSync();
  269. // console.timeEnd('computeUnitGaussianDensityTexture2d');
  270. const isoLevel = Math.exp(-props.smoothness) / densityTextureData.radiusFactor;
  271. const axisOrder = Vec3.create(0, 1, 2);
  272. const buffer = textureMesh?.doubleBuffer.get();
  273. const gv = extractIsosurface(ctx.webgl, densityTextureData.texture, densityTextureData.gridDim, densityTextureData.gridTexDim, densityTextureData.gridTexScale, densityTextureData.transform, isoLevel, false, true, axisOrder, buffer?.vertex, buffer?.group, buffer?.normal);
  274. const boundingSphere = Sphere3D.expand(Sphere3D(), structure.boundary.sphere, densityTextureData.maxRadius);
  275. const surface = TextureMesh.create(gv.vertexCount, 1, gv.vertexTexture, gv.groupTexture, gv.normalTexture, boundingSphere, textureMesh);
  276. (surface.meta as GaussianSurfaceMeta).resolution = densityTextureData.resolution;
  277. return surface;
  278. }
  279. export function StructureGaussianSurfaceTextureMeshVisual(materialId: number): ComplexVisual<StructureGaussianSurfaceMeshParams> {
  280. return ComplexTextureMeshVisual<StructureGaussianSurfaceMeshParams>({
  281. defaultProps: PD.getDefaultValues(StructureGaussianSurfaceMeshParams),
  282. createGeometry: createStructureGaussianSurfaceTextureMesh,
  283. createLocationIterator: ElementIterator.fromStructure,
  284. getLoci: getSerialElementLoci,
  285. eachLocation: eachSerialElement,
  286. setUpdateState: (state: VisualUpdateState, newProps: PD.Values<StructureGaussianSurfaceMeshParams>, currentProps: PD.Values<StructureGaussianSurfaceMeshParams>) => {
  287. if (newProps.resolution !== currentProps.resolution) state.createGeometry = true;
  288. if (newProps.radiusOffset !== currentProps.radiusOffset) state.createGeometry = true;
  289. if (newProps.smoothness !== currentProps.smoothness) state.createGeometry = true;
  290. if (newProps.ignoreHydrogens !== currentProps.ignoreHydrogens) state.createGeometry = true;
  291. if (newProps.traceOnly !== currentProps.traceOnly) state.createGeometry = true;
  292. if (newProps.includeParent !== currentProps.includeParent) state.createGeometry = true;
  293. if (newProps.smoothColors.name !== currentProps.smoothColors.name) {
  294. state.updateColor = true;
  295. } else if (newProps.smoothColors.name === 'on' && currentProps.smoothColors.name === 'on') {
  296. if (newProps.smoothColors.params.resolutionFactor !== currentProps.smoothColors.params.resolutionFactor) state.updateColor = true;
  297. if (newProps.smoothColors.params.sampleStride !== currentProps.smoothColors.params.sampleStride) state.updateColor = true;
  298. }
  299. },
  300. mustRecreate: (structure: Structure, props: PD.Values<StructureGaussianSurfaceMeshParams>, webgl?: WebGLContext) => {
  301. return !props.tryUseGpu || !webgl || !suitableForGpu(structure, props, webgl);
  302. },
  303. processValues: (values: TextureMeshValues, geometry: TextureMesh, props: PD.Values<GaussianSurfaceMeshParams>, theme: Theme, webgl?: WebGLContext) => {
  304. const { resolution, colorTexture } = geometry.meta as GaussianSurfaceMeta;
  305. const csp = getColorSmoothingProps(props.smoothColors, theme.color.preferSmoothing, resolution);
  306. if (csp && webgl) {
  307. applyTextureMeshColorSmoothing(values, csp.resolution, csp.stride, webgl, colorTexture);
  308. (geometry.meta as GaussianSurfaceMeta).colorTexture = values.tColorGrid.ref.value;
  309. }
  310. },
  311. dispose: (geometry: TextureMesh) => {
  312. geometry.vertexTexture.ref.value.destroy();
  313. geometry.groupTexture.ref.value.destroy();
  314. geometry.normalTexture.ref.value.destroy();
  315. geometry.doubleBuffer.destroy();
  316. (geometry.meta as GaussianSurfaceMeta).colorTexture?.destroy();
  317. }
  318. }, materialId);
  319. }