Skip to content

Commit

Permalink
fixed #3d-tasks/18679: Invoke toLowerCase of undefined. Enum should b…
Browse files Browse the repository at this point in the history
…e used instead of ccenum to generate reverse key.
  • Loading branch information
dumganhar committed Dec 12, 2024
1 parent 84790f5 commit 94bd99b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cocos/primitive/primitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { ccclass, type, serializable, editable } from 'cc.decorator';
import { createMesh } from '../3d/misc';
import { Mesh } from '../3d/assets/mesh';
import * as primitives from '.';
import { ccenum, cclegacy } from '../core';
import { Enum, cclegacy } from '../core';

enum PrimitiveType {
BOX = 0,
Expand All @@ -38,7 +38,7 @@ enum PrimitiveType {
PLANE = 6,
QUAD = 7,
}
ccenum(PrimitiveType);
Enum(PrimitiveType);

/**
* @en
Expand Down Expand Up @@ -81,7 +81,8 @@ export class Primitive extends Mesh {
* 根据`type`和`info`构建相应的网格。
*/
public onLoaded (): void {
createMesh(primitives[PrimitiveType[this.type].toLowerCase()](this.info), this);
const factory = primitives[PrimitiveType[this.type].toLowerCase()] as (arg: typeof this.info) => primitives.IGeometry;
createMesh(factory(this.info), this);
}
}

Expand Down

0 comments on commit 94bd99b

Please sign in to comment.