molstar
Version:
A comprehensive macromolecular library.
45 lines (44 loc) • 2.18 kB
JavaScript
/**
* Copyright (c) 2020-2025 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { createRenderable } from '../renderable.js';
import { createGraphicsRenderItem } from '../webgl/render-item.js';
import { GlobalUniformSchema, BaseSchema, AttributeSpec, InternalSchema, SizeSchema, ElementsSpec, ValueSpec, DefineSpec, GlobalTextureSchema, UniformSpec, GlobalDefineSchema } from './schema.js';
import { CylindersShaderCode } from '../shader-code.js';
import { ValueCell } from '../../mol-util/index.js';
export const CylindersSchema = {
...BaseSchema,
...SizeSchema,
aGroup: AttributeSpec('float32', 1, 0),
aStart: AttributeSpec('float32', 3, 0),
aEnd: AttributeSpec('float32', 3, 0),
aMapping: AttributeSpec('float32', 3, 0),
aScale: AttributeSpec('float32', 1, 0),
aCap: AttributeSpec('float32', 1, 0),
aColorMode: AttributeSpec('float32', 1, 0),
elements: ElementsSpec('uint32'),
padding: ValueSpec('number'),
uDoubleSided: UniformSpec('b', 'material'),
dIgnoreLight: DefineSpec('boolean'),
dCelShaded: DefineSpec('boolean'),
dXrayShaded: DefineSpec('string', ['off', 'on', 'inverted']),
dTransparentBackfaces: DefineSpec('string', ['off', 'on', 'opaque']),
dSolidInterior: DefineSpec('boolean'),
uBumpFrequency: UniformSpec('f', 'material'),
uBumpAmplitude: UniformSpec('f', 'material'),
dDualColor: DefineSpec('boolean'),
};
export function CylindersRenderable(ctx, id, values, state, materialId, transparency, globals) {
const schema = { ...GlobalUniformSchema, ...GlobalTextureSchema, ...GlobalDefineSchema, ...InternalSchema, ...CylindersSchema };
const renderValues = {
...values,
uObjectId: ValueCell.create(id),
dLightCount: ValueCell.create(globals.dLightCount),
dColorMarker: ValueCell.create(globals.dColorMarker),
};
const shaderCode = CylindersShaderCode;
const renderItem = createGraphicsRenderItem(ctx, 'triangles', shaderCode, schema, renderValues, materialId, transparency);
return createRenderable(renderItem, renderValues, state);
}