赞
踩
赞同来自:
刚学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;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。