How to use the troika-animation.setAnimationScheduler function in troika-animation

To help you get started, we’ve selected a few troika-animation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github protectwise / troika / packages / troika-xr / src / facade / WorldXRFacade.js View on Github external
afterUpdate() {
    // Disable pointer events on the onscreen canvas when in an immersive XR session
    this._togglePointerListeners(!this._isImmersive())

    super.afterUpdate()

    const {xrSession, _threeRenderer:renderer} = this

    const prevXrSession = _xrSessions.get(this)
    if (xrSession !== prevXrSession) {
      _xrSessions.set(this, xrSession)
      this.renderingScheduler = xrSession || window
      setAnimationScheduler(xrSession || window)
      if (xrSession) {
        let baseLayer = xrSession.renderState.baseLayer
        const gl = renderer.getContext()

        // If the session has an existing valid XRWebGLLayer, just grab its framebuffer.
        // Otherwise, create a new XRWebGLLayer
        if (baseLayer && baseLayer._glContext === gl) {
          renderer.setFramebuffer(baseLayer.framebuffer)
        } else {
          const promise = gl.makeXRCompatible ? gl.makeXRCompatible() : Promise.resolve() //not always implemented?
          promise.then(() => {
            if (this.xrSession === xrSession) {
              baseLayer = new XRWebGLLayer(xrSession, gl, {
                antialias: !!renderer.getContextAttributes().antialias
              })
              baseLayer._glContext = gl
github protectwise / troika / packages / troika-xr / src / webvr-deprecated / facade / WorldVrFacade.js View on Github external
afterUpdate() {
    // Disable pointer events on the onscreen canvas when in VR
    const vrDisplay = this._isInVR() ? this.vrDisplay : null
    this._togglePointerListeners(!vrDisplay)

    // Update the animation scheduler
    if (vrDisplay !== this._lastVrDisplay) {
      this._lastVrDisplay = vrDisplay
      this.renderingScheduler = vrDisplay || window
      setAnimationScheduler(vrDisplay || window)
    }

    super.afterUpdate()
  }

troika-animation

Troika Animation Utilities

MIT
Latest version published 1 month ago

Package Health Score

75 / 100
Full package analysis

Similar packages