废弃不常用的特效组件,减小包体

This commit is contained in:
dgflash
2024-08-09 12:11:09 +08:00
parent 20a38ec38f
commit 0eeb19d30f
7 changed files with 0 additions and 256 deletions

View File

@@ -1,12 +0,0 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "d5df6d89-615e-469b-8dcd-a7b33716abbe",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -1,102 +0,0 @@
// /*
// * @Author: dgflash
// * @Date: 2022-03-25 10:53:30
// * @LastEditors: dgflash
// * @LastEditTime: 2022-03-25 23:43:25
// */
// import { Material } from 'cc';
// import { Color, Component, macro, MeshRenderer, Node, renderer, v2, Vec2, Vec3, _decorator } from 'cc';
// const { ccclass, property } = _decorator;
// @ccclass('NavLine - 导航钱组件')
// export class NavLine extends Component {
// @property({ type: Node, displayName: "玩家模型节点" })
// player: Node = null!;
// @property({ type: MeshRenderer, displayName: "箭头网格", tooltip: "拖MeshRenderer组件到这里" })
// mesh: MeshRenderer = null!;
// @property({ displayName: "导航线颜色" })
// color: Color = new Color(255, 0, 0, 255);
// @property({ displayName: "执行间隔", tooltip: "多少帧执行一次数值越大动画越流程建议3-5", min: 1 })
// interval = 5;
// @property({ displayName: "箭头速度", tooltip: "控制材质texture位移数值越大动画播放越快", min: 0.1 })
// speed = 2;
// @property({ displayName: "箭头密度", tooltip: "控制箭头的密度,数值越大越密", min: 0.1 })
// density = 1;
// @property({ displayName: "角度变化", tooltip: "箭头是否有 x 欧拉角度变化,有高度的地形引导开启" })
// xEuler = true;
// /* 材质 */
// private mat: Material | renderer.MaterialInstance | null = null!;
// /* 导航线是否启动 */
// private inited = false;
// private distance: number = 0;
// private frame: number = 0;
// private start_pos = new Vec3();
// private target_pos = new Vec3();
// private tOffset = new Vec2(1, 1);
// start() {
// this.mat = this.mesh.material!;
// this.mat.setProperty("textureMoveSpeed", v2(0, this.speed)); // 根据需求也可以是 x 轴,动画移动
// this.hide();
// }
// /** 开始提示 */
// show(pos: Vec3) {
// this.node.setRotationFromEuler(0, this.player.eulerAngles.y, 0);
// this.mesh.node.active = true;
// this.frame = 0;
// this.inited = true;
// this.mat?.setProperty("mainColor", this.color);
// this.start_pos.set(this.player.worldPosition);
// this.target_pos.set(pos);
// this.setDistance();
// }
// /** 结束提示 */
// hide() {
// this.inited = false;
// this.mesh.node.active = false;
// }
// /** 距离实时计算 */
// private setDistance() {
// // 目标与
// this.distance = Vec3.distance(this.target_pos, this.player.worldPosition);
// this.node.setScale(this.node.scale.x, this.node.scale.y, this.distance);
// this.node.setWorldPosition(this.player.worldPosition);
// this.tOffset.y = this.distance * this.density;
// this.mat?.setProperty("tilingOffset", this.tOffset);
// if (this.xEuler) this.rotation(this.start_pos, this.target_pos);
// }
// /** 旋转朝向 */
// private rotation(start: Vec3, end: Vec3) {
// // 角色转动的角度, 相对Z轴逆时针为正方向
// var angle = Math.asin(Math.sin(Math.abs(end.y - start.y) / this.distance)) * macro.DEG % 360;
// var x = (end.y - start.y) > 0 ? -angle : angle;
// this.node.setRotationFromEuler(x, this.player.eulerAngles.y, 0);
// }
// update(dt: number) {
// if (this.inited) {
// this.frame++;
// if (this.frame >= this.interval) {
// this.setDistance()
// this.frame = 0;
// }
// }
// }
// }

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "41dced17-0943-4823-be09-d3349e68351f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -1,12 +0,0 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "d7e7035f-248d-4a35-852d-bb7c86170848",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "dd1877ff-a74c-498e-9b20-9cea493beb55",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -1,103 +0,0 @@
/*
* @Author: dgflash
* @Date: 2022-02-10 09:50:41
* @LastEditors: dgflash
* @LastEditTime: 2022-04-08 17:22:27
*/
import { Component, gfx, macro, Material, MeshRenderer, utils, Vec3, _decorator } from 'cc';
const { ccclass, property } = _decorator;
/** 绘制扇形网格 */
@ccclass('DrawSectorMesh')
export class DrawMeshSector extends Component {
@property({ type: Material })
public mat: Material | null = null;
@property({
tooltip: "外圈半径"
})
public radius: number = 5;
@property({
tooltip: "内圈半径"
})
public innerRadius: number = 1;
@property({
tooltip: "扇形角度"
})
public angledegree: number = 60;
start() {
this.createMesh()
}
createMesh() {
const model = this.addComponent(MeshRenderer)!;
const segments: number = Math.floor(this.angledegree / 4) + 1; // 三角形个数(平滑度)
var positions: number[] = []; // 顶点位置数据
// 组装顶点数据
var vertices_count: number = segments * 2 + 2; // vertices(顶点)的个数与triangles索引三角形顶点数匹配
var vertices: Array<Vec3> = new Array<Vec3>(vertices_count);
var angleRad: number = this.angledegree * macro.RAD; // 角度转弧度
var angleCur: number = angleRad;
var angledelta: number = angleRad / segments; // 每个三角形的弧度
for (var i = 0; i < vertices_count; i += 2) { // 扇形每二个三角形之间共用2个顶点所有生成时每次循环生成二个顶点
var cosA: number = Math.cos(angleCur);
var sinA: number = Math.sin(angleCur);
vertices[i] = new Vec3(this.radius * cosA, 0, this.radius * sinA); // 已知扇形外圈半径为斜边求x、z值得到第一个顶点位置外圈半径顶点
vertices[i + 1] = new Vec3(this.innerRadius * cosA, 0, this.innerRadius * sinA); // 已知扇形内圈半径为斜边求x、z值得到第二个顶点位置内圈半径顶点
angleCur -= angledelta;
positions.push(vertices[i].x);
positions.push(vertices[i].y);
positions.push(vertices[i].z);
positions.push(vertices[i + 1].x);
positions.push(vertices[i + 1].y);
positions.push(vertices[i + 1].z);
}
// 组装三角形数据
var indice_count: number = segments * 6; // 扇形外圈与扇形内圈会生成一个四边形即二个三角形6个顶点索引
var indices: Array<number> = new Array<number>(indice_count);
for (var i = 0, vi = 0; i < indice_count; i += 6, vi += 2) { // i为三角形顶点索引号vi为顶点位置索引
indices[i] = vi;
indices[i + 1] = vi + 3;
indices[i + 2] = vi + 1;
indices[i + 3] = vi + 2;
indices[i + 4] = vi + 3;
indices[i + 5] = vi;
}
// 组装UV数据
var uvs: number[] = [];
for (var i = 0; i < vertices_count; i++) {
var u = vertices[i].x / this.radius / 2 + 0.5
var v = vertices[i].z / this.radius / 2 + 0.5
uvs.push(u, v);
}
const primitiveMode = gfx.PrimitiveMode.TRIANGLE_FAN;
const attributes: any[] = [{
name: gfx.AttributeName.ATTR_NORMAL,
format: gfx.Format.RGB32F,
}];
var IGeometry = {
positions: positions,
indices: indices,
uvs: uvs,
primitiveMode: primitiveMode, // 默认值效果一样,需要研究作用
attributes: attributes // 默认值效果一样,需要研究作用
}
const mesh = utils.createMesh(IGeometry);
model.mesh = mesh;
model.material = this.mat;
}
}

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "ea0c1dde-7fa5-4be3-9d46-64b5a00ed95e",
"files": [],
"subMetas": {},
"userData": {}
}