Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Vector3.Slerp 球形插值
# [Vector3](Vector3.html).Slerp 球形插值 static function *Slerp* (*from* : [Vector3](Vector3.html), *to* : [Vector3](Vector3.html), *t* : float) : [Vector3](Vector3.html) *Description* 描述 Spherically interpolates between two vectors. 球形插值在两个向量之间。 我感觉叫“弧线插值”更直观一些。 Interpolates from towards to by amount t. The returned vector's [magnitude](Vector3.magnitude.html) will be interpolated between magnitudes of from and to. 通过 t 数值在 from 和 to 之间插值。返回的向量的长度将被插值到 from 到 to 的长度之间。 t is clamped between [0...1]. See Also: [Lerp](Vector3.Lerp.html) function. t 的值在[0...1]。 参见:[Lerp](Vector3.Lerp.html) 函数 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public Transform sunrise; public Transform sunset; void Update() { Vector3 center = sunrise.position + sunset.position * 0.5F; center -= new Vector3(0, 1, 0); Vector3 riseRelCenter = sunrise.position - center; Vector3 setRelCenter = sunset.position - center; transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, Time.time); transform.position += center; } } ``` ``` // Animates the position in an arc between sunrise and sunset. //在日出和日落之间动画弧线 var sunrise : Transform; var sunset : Transform; function Update () { // The center of the arc //弧线的中心 var center = (sunrise.position + sunset.position) * 0.5; // move the center a bit downwards to make the arc vertical //向下移动中心,垂直于弧线 center -= Vector3(0,1,0); // Interpolate over the arc relative to center //相对于中心在弧线上插值 var riseRelCenter = sunrise.position - center; var setRelCenter = sunset.position - center; transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, Time.time); transform.position += center; } ```
da
2022年5月23日 21:52
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码