Skip to content
Snippets Groups Projects
Select Git revision
  • df9efd05e6dc8abd67def6c39ed2ae180521af9f
  • master default protected
  • rednatco-v2
  • base-pairs-ladder
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

image.ts

Blame
  • image.ts 1.79 KiB
    /**
     * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
     *
     * @author Alexander Rose <alexander.rose@weirdbyte.de>
     */
    
    import { Renderable, RenderableState, createRenderable } from '../renderable';
    import { WebGLContext } from '../webgl/context';
    import { createGraphicsRenderItem } from '../webgl/render-item';
    import { AttributeSpec, Values, GlobalUniformSchema, InternalSchema, TextureSpec, ElementsSpec, DefineSpec, InternalValues, BaseSchema, UniformSpec } from './schema';
    import { ImageShaderCode } from '../shader-code';
    import { ValueCell } from '../../mol-util';
    import { InterpolationTypeNames } from '../../mol-geo/geometry/image/image';
    
    export const ImageSchema = {
        ...BaseSchema,
    
        aPosition: AttributeSpec('float32', 3, 0),
        aUv: AttributeSpec('float32', 2, 0),
    
        elements: ElementsSpec('uint32'),
    
        uImageTexDim: UniformSpec('v2'),
        tImageTex: TextureSpec('image-float32', 'rgba', 'float', 'nearest'),
        tGroupTex: TextureSpec('image-float32', 'alpha', 'float', 'nearest'),
    
        dInterpolation: DefineSpec('string', InterpolationTypeNames),
    };
    export type ImageSchema = typeof ImageSchema
    export type ImageValues = Values<ImageSchema>
    
    export function ImageRenderable(ctx: WebGLContext, id: number, values: ImageValues, state: RenderableState, materialId: number): Renderable<ImageValues> {
        const schema = { ...GlobalUniformSchema, ...InternalSchema, ...ImageSchema };
        const internalValues: InternalValues = {
            uObjectId: ValueCell.create(id),
            uPickable: ValueCell.create(state.pickable ? 1 : 0),
        };
        const shaderCode = ImageShaderCode;
        const renderItem = createGraphicsRenderItem(ctx, 'triangles', shaderCode, schema, { ...values, ...internalValues }, materialId);
        return createRenderable(renderItem, values, state);
    }