Bladeren bron

renamed isosurface geo to texture-mesh

Alexander Rose 6 jaren geleden
bovenliggende
commit
f057726262

+ 6 - 6
src/mol-geo/geometry/geometry.ts

@@ -21,7 +21,7 @@ import { TransformData } from './transform-data';
 import { Theme } from 'mol-theme/theme';
 import { RenderObjectValuesType } from 'mol-gl/render-object';
 import { ValueOf } from 'mol-util/type-helpers';
-import { Isosurface } from './isosurface/isosurface';
+import { TextureMesh } from './texture-mesh/texture-mesh';
 
 export type GeometryKindType = {
     'mesh': Mesh,
@@ -30,7 +30,7 @@ export type GeometryKindType = {
     'text': Text,
     'lines': Lines,
     'direct-volume': DirectVolume,
-    'isosurface': Isosurface,
+    'texture-mesh': TextureMesh,
 }
 export type GeometryKindParams = {
     'mesh': Mesh.Params,
@@ -39,7 +39,7 @@ export type GeometryKindParams = {
     'text': Text.Params,
     'lines': Lines.Params,
     'direct-volume': DirectVolume.Params,
-    'isosurface': Isosurface.Params,
+    'texture-mesh': TextureMesh.Params,
 }
 export type GeometryKind = keyof GeometryKindType
 export type Geometry = ValueOf<GeometryKindType>
@@ -66,7 +66,7 @@ export namespace Geometry {
             case 'text': return geometry.charCount * 2 * 3
             case 'lines': return geometry.lineCount * 2 * 3
             case 'direct-volume': return 12 * 3
-            case 'isosurface': return geometry.vertexCount.ref.value * 3
+            case 'texture-mesh': return geometry.vertexCount.ref.value * 3
         }
     }
 
@@ -80,7 +80,7 @@ export namespace Geometry {
                 return getDrawCount(geometry) === 0 ? 0 : (arrayMax(geometry.groupBuffer.ref.value) + 1)
             case 'direct-volume':
                 return 1
-            case 'isosurface':
+            case 'texture-mesh':
                 return geometry.groupCount.ref.value
         }
     }
@@ -94,7 +94,7 @@ export namespace Geometry {
             case 'text': return Text.Utils as any
             case 'lines': return Lines.Utils as any
             case 'direct-volume': return DirectVolume.Utils as any
-            case 'isosurface': return Isosurface.Utils as any
+            case 'texture-mesh': return TextureMesh.Utils as any
         }
         throw new Error('unknown geometry kind')
     }

+ 32 - 32
src/mol-geo/geometry/isosurface/isosurface.ts → src/mol-geo/geometry/texture-mesh/texture-mesh.ts

@@ -17,18 +17,18 @@ import { Color } from 'mol-util/color';
 import { BaseGeometry } from '../base';
 import { createEmptyOverpaint } from '../overpaint-data';
 import { createEmptyTransparency } from '../transparency-data';
-import { IsosurfaceValues } from 'mol-gl/renderable/isosurface';
+import { TextureMeshValues } from 'mol-gl/renderable/texture-mesh';
 import { calculateTransformBoundingSphere } from 'mol-gl/renderable/util';
 import { Texture } from 'mol-gl/webgl/texture';
 import { Vec2 } from 'mol-math/linear-algebra';
 import { fillSerial } from 'mol-util/array';
 
-export interface Isosurface {
-    readonly kind: 'isosurface',
+export interface TextureMesh {
+    readonly kind: 'texture-mesh',
 
-    /** Number of vertices in the isosurface */
+    /** Number of vertices in the texture-mesh */
     readonly vertexCount: ValueCell<number>,
-    /** Number of groups in the isosurface */
+    /** Number of groups in the texture-mesh */
     readonly groupCount: ValueCell<number>,
 
     readonly geoTextureDim: ValueCell<Vec2>,
@@ -39,20 +39,20 @@ export interface Isosurface {
     readonly boundingSphere: ValueCell<Sphere3D>,
 }
 
-export namespace Isosurface {
-    export function create(vertexCount: number, groupCount: number, vertexGroupTexture: Texture, normalTexture: Texture, boundingSphere: Sphere3D, isosurface?: Isosurface): Isosurface {
+export namespace TextureMesh {
+    export function create(vertexCount: number, groupCount: number, vertexGroupTexture: Texture, normalTexture: Texture, boundingSphere: Sphere3D, textureMesh?: TextureMesh): TextureMesh {
         const { width, height } = vertexGroupTexture
-        if (isosurface) {
-            ValueCell.update(isosurface.vertexCount, vertexCount)
-            ValueCell.update(isosurface.groupCount, groupCount)
-            ValueCell.update(isosurface.geoTextureDim, Vec2.set(isosurface.geoTextureDim.ref.value, width, height))
-            ValueCell.update(isosurface.vertexGroupTexture, vertexGroupTexture)
-            ValueCell.update(isosurface.normalTexture, normalTexture)
-            ValueCell.update(isosurface.boundingSphere, boundingSphere)
-            return isosurface
+        if (textureMesh) {
+            ValueCell.update(textureMesh.vertexCount, vertexCount)
+            ValueCell.update(textureMesh.groupCount, groupCount)
+            ValueCell.update(textureMesh.geoTextureDim, Vec2.set(textureMesh.geoTextureDim.ref.value, width, height))
+            ValueCell.update(textureMesh.vertexGroupTexture, vertexGroupTexture)
+            ValueCell.update(textureMesh.normalTexture, normalTexture)
+            ValueCell.update(textureMesh.boundingSphere, boundingSphere)
+            return textureMesh
         } else {
             return {
-                kind: 'isosurface',
+                kind: 'texture-mesh',
                 vertexCount: ValueCell.create(vertexCount),
                 groupCount: ValueCell.create(groupCount),
                 geoTextureDim: ValueCell.create(Vec2.create(width, height)),
@@ -63,8 +63,8 @@ export namespace Isosurface {
         }
     }
 
-    export function createEmpty(isosurface?: Isosurface): Isosurface {
-        return {} as Isosurface // TODO
+    export function createEmpty(textureMesh?: TextureMesh): TextureMesh {
+        return {} as TextureMesh // TODO
     }
 
     export const Params = {
@@ -75,7 +75,7 @@ export namespace Isosurface {
     }
     export type Params = typeof Params
 
-    export const Utils: GeometryUtils<Isosurface, Params> = {
+    export const Utils: GeometryUtils<TextureMesh, Params> = {
         Params,
         createEmpty,
         createValues,
@@ -86,26 +86,26 @@ export namespace Isosurface {
         updateRenderableState: BaseGeometry.updateRenderableState
     }
 
-    function createValues(isosurface: Isosurface, transform: TransformData, locationIt: LocationIterator, theme: Theme, props: PD.Values<Params>): IsosurfaceValues {
+    function createValues(textureMesh: TextureMesh, transform: TransformData, locationIt: LocationIterator, theme: Theme, props: PD.Values<Params>): TextureMeshValues {
         const { instanceCount, groupCount } = locationIt
         const color = createColors(locationIt, theme.color)
         const marker = createMarkers(instanceCount * groupCount)
         const overpaint = createEmptyOverpaint()
         const transparency = createEmptyTransparency()
 
-        const counts = { drawCount: isosurface.vertexCount.ref.value, groupCount, instanceCount }
+        const counts = { drawCount: textureMesh.vertexCount.ref.value, groupCount, instanceCount }
 
-        const transformBoundingSphere = calculateTransformBoundingSphere(isosurface.boundingSphere.ref.value, transform.aTransform.ref.value, transform.instanceCount.ref.value)
+        const transformBoundingSphere = calculateTransformBoundingSphere(textureMesh.boundingSphere.ref.value, transform.aTransform.ref.value, transform.instanceCount.ref.value)
 
         return {
-            uGeoTexDim: isosurface.geoTextureDim,
-            tPositionGroup: isosurface.vertexGroupTexture,
-            tNormal: isosurface.normalTexture,
+            uGeoTexDim: textureMesh.geoTextureDim,
+            tPositionGroup: textureMesh.vertexGroupTexture,
+            tNormal: textureMesh.normalTexture,
 
             // aGroup is used as a vertex index here and the group id is retirieved from tPositionGroup
-            aGroup: ValueCell.create(fillSerial(new Float32Array(isosurface.vertexCount.ref.value))),
+            aGroup: ValueCell.create(fillSerial(new Float32Array(textureMesh.vertexCount.ref.value))),
             boundingSphere: ValueCell.create(transformBoundingSphere),
-            invariantBoundingSphere: isosurface.boundingSphere,
+            invariantBoundingSphere: textureMesh.boundingSphere,
 
             ...color,
             ...marker,
@@ -121,13 +121,13 @@ export namespace Isosurface {
         }
     }
 
-    function createValuesSimple(isosurface: Isosurface, props: Partial<PD.Values<Params>>, colorValue: Color, sizeValue: number, transform?: TransformData) {
+    function createValuesSimple(textureMesh: TextureMesh, props: Partial<PD.Values<Params>>, colorValue: Color, sizeValue: number, transform?: TransformData) {
         const s = BaseGeometry.createSimple(colorValue, sizeValue, transform)
         const p = { ...PD.getDefaultValues(Params), ...props }
-        return createValues(isosurface, s.transform, s.locationIterator, s.theme, p)
+        return createValues(textureMesh, s.transform, s.locationIterator, s.theme, p)
     }
 
-    function updateValues(values: IsosurfaceValues, props: PD.Values<Params>) {
+    function updateValues(values: TextureMeshValues, props: PD.Values<Params>) {
         if (Color.fromNormalizedArray(values.uHighlightColor.ref.value, 0) !== props.highlightColor) {
             ValueCell.update(values.uHighlightColor, Color.toArrayNormalized(props.highlightColor, values.uHighlightColor.ref.value, 0))
         }
@@ -142,8 +142,8 @@ export namespace Isosurface {
         ValueCell.updateIfChanged(values.dFlipSided, props.flipSided)
     }
 
-    function updateBoundingSphere(values: IsosurfaceValues, isosurface: Isosurface) {
-        const invariantBoundingSphere = isosurface.boundingSphere.ref.value
+    function updateBoundingSphere(values: TextureMeshValues, textureMesh: TextureMesh) {
+        const invariantBoundingSphere = textureMesh.boundingSphere.ref.value
         const boundingSphere = calculateTransformBoundingSphere(invariantBoundingSphere, values.aTransform.ref.value, values.instanceCount.ref.value)
         if (!Sphere3D.equals(boundingSphere, values.boundingSphere.ref.value)) {
             ValueCell.update(values.boundingSphere, boundingSphere)

+ 6 - 6
src/mol-gl/render-object.ts

@@ -14,7 +14,7 @@ import { PointsValues, PointsRenderable } from './renderable/points';
 import { LinesValues, LinesRenderable } from './renderable/lines';
 import { SpheresValues, SpheresRenderable } from './renderable/spheres';
 import { TextValues, TextRenderable } from './renderable/text';
-import { IsosurfaceValues, IsosurfaceRenderable } from './renderable/isosurface';
+import { TextureMeshValues, TextureMeshRenderable } from './renderable/texture-mesh';
 
 const getNextId = idFactory(0, 0x7FFFFFFF)
 
@@ -27,11 +27,11 @@ export interface SpheresRenderObject extends BaseRenderObject { type: 'spheres',
 export interface TextRenderObject extends BaseRenderObject { type: 'text', values: TextValues }
 export interface LinesRenderObject extends BaseRenderObject { type: 'lines', values: LinesValues }
 export interface DirectVolumeRenderObject extends BaseRenderObject { type: 'direct-volume', values: DirectVolumeValues }
-export interface IsosurfaceRenderObject extends BaseRenderObject { type: 'isosurface', values: IsosurfaceValues }
+export interface TextureMeshRenderObject extends BaseRenderObject { type: 'texture-mesh', values: TextureMeshValues }
 
 //
 
-export type GraphicsRenderObject = MeshRenderObject | PointsRenderObject | SpheresRenderObject | TextRenderObject | LinesRenderObject | DirectVolumeRenderObject | IsosurfaceRenderObject
+export type GraphicsRenderObject = MeshRenderObject | PointsRenderObject | SpheresRenderObject | TextRenderObject | LinesRenderObject | DirectVolumeRenderObject | TextureMeshRenderObject
 
 export type RenderObjectKindType = {
     'mesh': MeshRenderObject
@@ -40,7 +40,7 @@ export type RenderObjectKindType = {
     'text': TextRenderObject
     'lines': LinesRenderObject
     'direct-volume': DirectVolumeRenderObject
-    'isosurface': IsosurfaceRenderObject
+    'texture-mesh': TextureMeshRenderObject
 }
 export type RenderObjectValuesType = {
     'mesh': MeshValues
@@ -49,7 +49,7 @@ export type RenderObjectValuesType = {
     'text': TextValues
     'lines': LinesValues
     'direct-volume': DirectVolumeValues
-    'isosurface': IsosurfaceValues
+    'texture-mesh': TextureMeshValues
 }
 export type RenderObjectType = keyof RenderObjectKindType
 
@@ -67,6 +67,6 @@ export function createRenderable(ctx: WebGLContext, o: GraphicsRenderObject): Re
         case 'text': return TextRenderable(ctx, o.id, o.values, o.state, o.materialId)
         case 'lines': return LinesRenderable(ctx, o.id, o.values, o.state, o.materialId)
         case 'direct-volume': return DirectVolumeRenderable(ctx, o.id, o.values, o.state, o.materialId)
-        case 'isosurface': return IsosurfaceRenderable(ctx, o.id, o.values, o.state, o.materialId)
+        case 'texture-mesh': return TextureMeshRenderable(ctx, o.id, o.values, o.state, o.materialId)
     }
 }

+ 5 - 5
src/mol-gl/renderable/isosurface.ts → src/mol-gl/renderable/texture-mesh.ts

@@ -11,7 +11,7 @@ import { GlobalUniformSchema, BaseSchema, DefineSpec, Values, InternalSchema, In
 import { MeshShaderCode } from '../shader-code';
 import { ValueCell } from 'mol-util';
 
-export const IsosurfaceSchema = {
+export const TextureMeshSchema = {
     ...BaseSchema,
 
     uGeoTexDim: UniformSpec('v2'),
@@ -24,11 +24,11 @@ export const IsosurfaceSchema = {
     dFlipSided: DefineSpec('boolean'),
     dGeoTexture: DefineSpec('boolean'),
 }
-export type IsosurfaceSchema = typeof IsosurfaceSchema
-export type IsosurfaceValues = Values<IsosurfaceSchema>
+export type TextureMeshSchema = typeof TextureMeshSchema
+export type TextureMeshValues = Values<TextureMeshSchema>
 
-export function IsosurfaceRenderable(ctx: WebGLContext, id: number, values: IsosurfaceValues, state: RenderableState, materialId: number): Renderable<IsosurfaceValues> {
-    const schema = { ...GlobalUniformSchema, ...InternalSchema, ...IsosurfaceSchema }
+export function TextureMeshRenderable(ctx: WebGLContext, id: number, values: TextureMeshValues, state: RenderableState, materialId: number): Renderable<TextureMeshValues> {
+    const schema = { ...GlobalUniformSchema, ...InternalSchema, ...TextureMeshSchema }
     const internalValues: InternalValues = {
         uObjectId: ValueCell.create(id),
         uPickable: ValueCell.create(state.pickable ? 1 : 0)

+ 6 - 6
src/tests/browser/marching-cubes.ts

@@ -16,7 +16,7 @@ import { Vec3 } from 'mol-math/linear-algebra';
 import { computeMarchingCubesMesh } from 'mol-geo/util/marching-cubes/algorithm';
 import { Mesh } from 'mol-geo/geometry/mesh/mesh';
 import { ColorNames } from 'mol-util/color/tables';
-import { Isosurface } from 'mol-geo/geometry/isosurface/isosurface';
+import { TextureMesh } from 'mol-geo/geometry/texture-mesh/texture-mesh';
 import { calcActiveVoxels } from 'mol-gl/compute/marching-cubes/active-voxels';
 import { createHistogramPyramid } from 'mol-gl/compute/histogram-pyramid/reduction';
 import { createIsosurfaceBuffers } from 'mol-gl/compute/marching-cubes/isosurface';
@@ -110,13 +110,13 @@ async function init() {
     const mcBoundingSphere = Sphere3D.zero()
     Sphere3D.addVec3(mcBoundingSphere, mcBoundingSphere, densityTextureData.gridDimension)
     console.log('mcBoundingSphere', mcBoundingSphere, densityTextureData.gridDimension)
-    const mcIsosurface = Isosurface.create(gv.vertexCount, 1, gv.vertexGroupTexture, gv.normalTexture, mcBoundingSphere)
+    const mcIsosurface = TextureMesh.create(gv.vertexCount, 1, gv.vertexGroupTexture, gv.normalTexture, mcBoundingSphere)
     const mcIsoSurfaceProps = { doubleSided: true, flatShaded: false, alpha: 1.0 }
-    const mcIsoSurfaceValues = Isosurface.Utils.createValuesSimple(mcIsosurface, mcIsoSurfaceProps, Color(0x112299), 1)
+    const mcIsoSurfaceValues = TextureMesh.Utils.createValuesSimple(mcIsosurface, mcIsoSurfaceProps, Color(0x112299), 1)
     // console.log('mcIsoSurfaceValues', mcIsoSurfaceValues)
-    const mcIsoSurfaceState = Isosurface.Utils.createRenderableState(mcIsoSurfaceProps)
-    const mcIsoSurfaceRenderObject = createRenderObject('isosurface', mcIsoSurfaceValues, mcIsoSurfaceState, -1)
-    const mcIsoSurfaceRepr = Representation.fromRenderObject('isosurface', mcIsoSurfaceRenderObject)
+    const mcIsoSurfaceState = TextureMesh.Utils.createRenderableState(mcIsoSurfaceProps)
+    const mcIsoSurfaceRenderObject = createRenderObject('texture-mesh', mcIsoSurfaceValues, mcIsoSurfaceState, -1)
+    const mcIsoSurfaceRepr = Representation.fromRenderObject('texture-mesh', mcIsoSurfaceRenderObject)
 
     canvas3d.add(mcIsoSurfaceRepr)
     canvas3d.resetCamera()