ecsyjs / ecsy

Entity Component System for javascript
https://ecsyjs.github.io/ecsy/
MIT License
1.11k stars 115 forks source link

custom type causes error #214

Closed iam-yan closed 4 years ago

iam-yan commented 4 years ago

ver

0.3.2

Create type

export class Vector3 {
  x: number;
  y: number;
  z: number;

  constructor() {
    this.x = 0;
    this.y = 0;
    this.z = 0;
  }
  set(x, y, z) {
    this.x = x;
    this.y = y;
    this.z = z;
    return this;
  }
  copy(source) {
    this.x = source.x;
    this.y = source.y;
    this.z = source.z;
    return this;
  }
  clone() {
    return new Vector3().set(this.x, this.y, this.z);
  }
}

export const ThreeTypes = {
  Vector3: createType({
    name: 'Vector3',
    default: new Vector3(),
    copy: copyCopyable,
    clone: cloneClonable,
  }),
};

Use custom type

export class ScaleComponent extends Component<ScaleComponent> {
  value: THREE.Vector3;
}
ScaleComponent.schema = {
  value: { default: new THREE.Vector3(), type: ThreeTypes.Vector3 },
};

Error

image

Uncaught TypeError: Cannot read property 'name' of undefined
    at getName (Utils.js:7)
    at queryKey (Utils.js:32)
    at QueryManager.getQuery (QueryManager.js:94)
    at EntityManager.queryComponents (EntityManager.js:273)
   ...