gaussian-surface-mesh.ts 21 KB

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