예제 #1
0
 private void Injecting(AvaterProvider avaterProvider, AvaterSynchronizer avaterSynchronizer, Configs config)
 {
     _avaterProvider = avaterProvider;
     _synchronizer   = avaterSynchronizer;
     _config         = config;
     Itinialzie();
 }
        private void Inject(IStageScaler stageScaler, StageController stageController, Configs configs)
        {
            _stageScaler     = stageScaler;
            _stageController = stageController;
            _configs         = configs;

            if (_configs.IsVrMode)
            {
                //VRの座標に追従
                this.UpdateAsObservable()
                .Subscribe(_ =>
                {
                    if (_trackingTarget == null)
                    {
                        return;
                    }
                    transform.SetPositionAndRotation(_trackingTarget.position, _trackingTarget.rotation);
                });
            }
            else
            {
                //受信データに追従
                this.UpdateAsObservable()
                .Subscribe(_ =>
                {
                    // スケール計算
                    var scale = _stageScaler.StageScale.Value * scaleOffset;

                    // 現在の原点座標
                    var root = _stageController.Root.position;

                    // 線形補間
                    var np = Vector3.Lerp(transform.position, root + _originalTargetPosition * scale,
                                          Time.deltaTime * LerpParam);
                    var nr = Quaternion.Lerp(transform.rotation, _originalTargetRotation,
                                             Time.deltaTime * LerpParam);

                    transform.SetPositionAndRotation(np, nr);
                });
            }
        }