Skip to content
Snippets Groups Projects
Select Git revision
  • 8c49783c122dc352e5bd14736cc3d85682343608
  • master default protected
  • rednatco-v2
  • 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
  • servers
  • 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

font-atlas.ts

Blame
  • mesh.ts 1.72 KiB
    /**
     * Copyright (c) 2018-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 { GlobalUniformSchema, BaseSchema, AttributeSpec, ElementsSpec, DefineSpec, Values, InternalSchema, InternalValues, GlobalTextureSchema, ValueSpec } from './schema';
    import { MeshShaderCode } from '../shader-code';
    import { ValueCell } from '../../mol-util';
    
    export const MeshSchema = {
        ...BaseSchema,
        aGroup: AttributeSpec('float32', 1, 0),
        aPosition: AttributeSpec('float32', 3, 0),
        aNormal: AttributeSpec('float32', 3, 0),
        elements: ElementsSpec('uint32'),
        dFlatShaded: DefineSpec('boolean'),
        dDoubleSided: DefineSpec('boolean'),
        dFlipSided: DefineSpec('boolean'),
        dIgnoreLight: DefineSpec('boolean'),
        dXrayShaded: DefineSpec('boolean'),
        meta: ValueSpec('unknown')
    } as const;
    export type MeshSchema = typeof MeshSchema
    export type MeshValues = Values<MeshSchema>
    
    export function MeshRenderable(ctx: WebGLContext, id: number, values: MeshValues, state: RenderableState, materialId: number): Renderable<MeshValues> {
        const schema = { ...GlobalUniformSchema, ...GlobalTextureSchema, ...InternalSchema, ...MeshSchema };
        const internalValues: InternalValues = {
            uObjectId: ValueCell.create(id),
        };
        const shaderCode = MeshShaderCode;
        const renderItem = createGraphicsRenderItem(ctx, 'triangles', shaderCode, schema, { ...values, ...internalValues }, materialId);
    
        return createRenderable(renderItem, values, state);
    }