coscos3D 基础教程与实践

目录

1.cocos creator 3D坐标系

2.TS 组件代码介绍

3.vec3

4.node基础属性与缩放

5.欧拉角与四元数

6.Node 旋转

7.摄像机

8.模型显示以及动画播放

9.常用3DShader 

10.天空盒的使用


待续...


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 长

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值