当前位置:   article > 正文

html5怎么让物体自然旋转,3D中摄像机绕物体旋转该如何实现?

laya模型围绕摄像机旋转

1446bbcfbd7fca352609b14df91ea593.png

赞同来自:

刚学Laya,用unity的C#脚本改了一版Laya的TS版本代码出来,你可以试一下,应该可以用,刚学,改的比较乱,不要介意。这个是带缓动的,电脑上OK,移动端没试,有问题调试着改一改就OK啦。。import Transform3D = Laya.Transform3D;

import Vector3 = laya.d3.math.Vector3;

import Quaternion = laya.d3.math.Quaternion;

/*

用法:

//初始化照相机

var camera = this.newScene.addChild(new Laya.Camera(0, 0.1, 100)) as Laya.Camera;

camera.transform.rotationEuler = new Laya.Vector3(-32, -75, 0);

camera.transform.position =new Laya.Vector3(-8.2, 5.3, 2.2);

var modelViewer = camera.addComponent(ModelViewer);

modelViewer.AroundPos = plane.transform.position;

*/

export default class ModelViewer extends Laya.Script {

// Text m_debugTip;

public canRotation_X: boolean = true;

public canRotation_Y: boolean = true;

public canScale: boolean = true;

///

/// Around center.

///

//public target: Transform3D;

public AroundPos: Vector3 = new Vector3();

///

/// Settings of mouse button, pointer and scrollwheel.

///

public mouseSettings: MouseSettings = new MouseSettings(0, 1, 0.3);

///

/// Range limit of angle.

///

public angleRange: MyRange = new MyRange(5, 90);

///

/// Range limit of distance.

///

public distanceRange: MyRange = new MyRange(1, 10);

///

/// Damper for move and rotate.

///

///[Range(0, 10)]

public damper: number = 5;

///

/// Camera current angls.

///

public CurrentAngles: Vector3 = new Vector3();

public CurrentAnglesTemp: Vector3 = new Vector3();

///

/// Current distance from camera to target.

///

public CurrentDistance: number;

///

/// Camera target angls.

///

protected targetAngles: Vector3 = new Vector3();

///

/// Target distance from camera to target.

///

protected targetDistance: number;

//protected camera: Laya.Camera;

constructor() {

super();

}

public transform: Transform3D;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/214623
推荐阅读
相关标签
  

闽ICP备14008679号