All files / Sources/IO/Core/ImageStream DefaultProtocol.js

0% Statements 0/17
0% Branches 0/14
0% Functions 0/17
0% Lines 0/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54                                                                                                           
export default function createMethods(session) {
  return {
    subscribeToImageStream: (callback) =>
      session.subscribe('viewport.image.push.subscription', callback),
    unsubscribeToImageStream: (subscription) =>
      session.unsubscribe(subscription),
    registerView: (viewId) =>
      session.call('viewport.image.push.observer.add', [viewId]),
    unregisterView: (viewId) =>
      session.call('viewport.image.push.observer.remove', [viewId]),
    enableView: (viewId, enabled) =>
      session.call('viewport.image.push.enabled', [viewId, enabled]),
    render: (options = { size: [400, 400], view: -1 }) =>
      session.call('viewport.image.push', [options]),
    resetCamera: (view = -1) => session.call('viewport.camera.reset', [view]),
    invalidateCache: (viewId) =>
      session.call('viewport.image.push.invalidate.cache', [viewId]),
    setQuality: (viewId, quality, ratio = 1) =>
      session.call('viewport.image.push.quality', [viewId, quality, ratio]),
    setSize: (viewId, width = 400, height = 400) =>
      session.call('viewport.image.push.original.size', [
        viewId,
        width,
        height,
      ]),
    setServerAnimationFPS: (fps = 30) =>
      session.call('viewport.image.animation.fps.max', [fps]),
    getServerAnimationFPS: () =>
      session.call('viewport.image.animation.fps.get', []),
    startAnimation: (viewId = -1) =>
      session.call('viewport.image.animation.start', [viewId]),
    stopAnimation: (viewId = -1) =>
      session.call('viewport.image.animation.stop', [viewId]),
    updateCamera: (viewId, focalPoint, viewUp, position, forceUpdate = true) =>
      session.call('viewport.camera.update', [
        viewId ?? -1,
        focalPoint,
        viewUp,
        position,
        forceUpdate,
      ]),
    updateCameraParameters: (
      viewId = -1,
      parameters = {},
      forceUpdate = true
    ) =>
      session.call('viewport.camera.update.params', [
        viewId,
        parameters,
        forceUpdate,
      ]),
  };
}