mesh.spec.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { createRenderObject } from '../render-object';
  7. import { Scene } from '../scene';
  8. import { getGLContext, tryGetGLContext } from './gl';
  9. import { setDebugMode } from '../../mol-util/debug';
  10. import { ColorNames } from '../../mol-util/color/names';
  11. import { ParamDefinition as PD } from '../../mol-util/param-definition';
  12. import { Mesh } from '../../mol-geo/geometry/mesh/mesh';
  13. export function createMesh() {
  14. const mesh = Mesh.createEmpty();
  15. const props = PD.getDefaultValues(Mesh.Params);
  16. const values = Mesh.Utils.createValuesSimple(mesh, props, ColorNames.orange, 1);
  17. const state = Mesh.Utils.createRenderableState(props);
  18. return createRenderObject('mesh', values, state, -1);
  19. }
  20. describe('mesh', () => {
  21. const ctx = tryGetGLContext(32, 32);
  22. (ctx ? it : it.skip)('basic', async () => {
  23. const ctx = getGLContext(32, 32);
  24. const scene = Scene.create(ctx);
  25. const mesh = createMesh();
  26. scene.add(mesh);
  27. setDebugMode(true);
  28. expect(() => scene.commit()).not.toThrow();
  29. setDebugMode(false);
  30. ctx.destroy();
  31. });
  32. });