目录
待续...
1.cocos creator 3D坐标系
水平向右边 x轴; 竖直向上 y轴; 垂直于屏幕向外: Z;
物体的前方: (-z), 右边(+x) 上面(+y)
3D坐标系:右手,左手坐标;
2.TS 组件代码介绍
//具体ts 脚本使用教程地址:
https://blog.youkuaiyun.com/osuckseed/article/details/103697957
//从指定模块导出对应的符号
import { _decorator, Component, Node,Vec3, CCObject } from "cc";
//装饰器 编辑器装载脚本代码的时候读取的
//ccclass :指定类为组件类
//property:作为属性绑定为到编辑器
const { ccclass, property } = _decorator;
//装饰器以@开头 编辑器识别后把它作为组件类
//export:导出类 import{gameMgr} frrom "./gameMgr"
@ccclass("gameMgr")
export class gameMgr extends Component {
/* class member could be defined like this */
// dummy = '';
/* use `property` decorator if your want the member to be serializable */
// @property
// serializableDummy = 0;
@property
is_debug:boolean =true;
@property(Node)
test_node:Node=null;
@property([Node])
arry_node:Array<Node> =[];
start () {
// Your initialization goes here.
}
// update (deltaTime: number) {
// // Your update function goes here.
// }
}
3.vec3
1: 数据成员: x, y, z;
2: 常用的单位向量: UNIT_X: (1, 0, 0), UNIT_Y(0, 1, 0), UNIT_Y(0, 0, 1); ZERO: (0, 0, 0), ONE: (1, 1, 1), NEG_ONE (-1, -1, -1);
3: 常用的向量方法: 向量长度 Vec3.Len; 向量加减法: add, sub; 两个向量距离Vec3.distance; 两个向量线性插值: lerp; 两个向量点乘dot, 叉积(cross); 两个向量单位化:normalize;
4: 标量分解到对应向量: dir: (x, y, z), len 是dir 长