/** * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose */ import { Renderable, RenderableState, createRenderable } from '../renderable' import { WebGLContext } from '../webgl/context'; import { createRenderItem } from '../webgl/render-item'; import { GlobalUniformSchema, BaseSchema, AttributeSpec, DefineSpec, Values, InternalSchema, SizeSchema, ElementsSpec, InternalValues } from './schema'; import { ValueCell } from 'mol-util'; import { LinesShaderCode } from '../shader-code'; export const LinesSchema = { ...BaseSchema, ...SizeSchema, aMapping: AttributeSpec('float32', 2, 0), aStart: AttributeSpec('float32', 3, 0), aEnd: AttributeSpec('float32', 3, 0), elements: ElementsSpec('uint32'), dLineSizeAttenuation: DefineSpec('boolean'), dDoubleSided: DefineSpec('boolean'), dFlipSided: DefineSpec('boolean'), } export type LinesSchema = typeof LinesSchema export type LinesValues = Values export function LinesRenderable(ctx: WebGLContext, id: number, values: LinesValues, state: RenderableState): Renderable { const schema = { ...GlobalUniformSchema, ...InternalSchema, ...LinesSchema } const internalValues: InternalValues = { uObjectId: ValueCell.create(id), uPickable: ValueCell.create(state.pickable ? 1 : 0) } const shaderCode = LinesShaderCode const renderItem = createRenderItem(ctx, 'triangles', shaderCode, schema, { ...values, ...internalValues }) return createRenderable(renderItem, values, state); }