How to use the troika-core.utils.assignIf function in troika-core

To help you get started, we’ve selected a few troika-core 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-3d / src / react / Canvas3D.jsx View on Github external
objects: props.objects,
            fog: props.fog,
            onBackgroundClick: props.onBackgroundClick
          },
          context.worldProps,
          props.worldProps
        )
      }),
      props.children
    )
  }
}

Canvas3D.displayName = 'Canvas3D'

Canvas3D.propTypes = utils.assignIf(
  {
    backgroundColor: T.any,
    lights: T.array,
    camera: T.object,
    objects: T.oneOfType([T.array, T.object]).isRequired,
    antialias: T.bool,
    onBackgroundClick: T.func,
    rendererClass: T.func
  },
  ReactCanvasBase.commonPropTypes
)

/**
 * Ancestors React components may provide these context values to override
 * how the world is created, e.g. switching to a WebXR-aware world impl
 */
github protectwise / troika / packages / troika-2d / src / react / Canvas2D.jsx View on Github external
utils.assign({}, props, {
        worldFacade: props.worldFacade || World2DFacade,
        worldProps: utils.assign({}, {
          backgroundColor: props.backgroundColor,
          onBackgroundClick: props.onBackgroundClick,
          objects: props.objects
        }, props.worldProps)
      }),
      props.children
    )
  }
}

Canvas2D.displayName = 'Canvas2D'

Canvas2D.propTypes = utils.assignIf(
  {
    backgroundColor: T.any,
    objects: T.oneOfType([T.array, T.object]).isRequired,
    onBackgroundClick: T.func
  },
  ReactCanvasBase.commonPropTypes
)

export default Canvas2D