Skip to content

Commit

Permalink
Rename ability to component. (galacean#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
eyworldwide authored Mar 2, 2022
1 parent 29aebf3 commit 5401e8a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/ComponentsDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export class ComponentsDependencies {
private constructor() {}
}

export function dependencies(...abilityClass: ComponentConstructor[]) {
export function dependencies(...componentClass: ComponentConstructor[]) {
return function <T extends ComponentConstructor>(target: T): void {
abilityClass.forEach((ability) => ComponentsDependencies.register(target, ability));
componentClass.forEach((component) => ComponentsDependencies.register(target, component));
};
}
6 changes: 3 additions & 3 deletions packages/core/src/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ export class Entity extends EngineObject {
if (this._destroyed) return;

super.destroy();
const abilityArray = this._components;
for (let i = abilityArray.length - 1; i >= 0; i--) {
abilityArray[i].destroy();
const components = this._components;
for (let i = components.length - 1; i >= 0; i--) {
components[i].destroy();
}
this._components.length = 0;

Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/lighting/KHR_lights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ class KHR_lights {
for (let i = 0; i < lights.length; i++) {
const { name, type, spot } = lights[i];
let { color, intensity } = lights[i];
let ability;
let component;
let props;
color = color ? color : [1, 1, 1];
intensity = intensity === undefined ? 1 : intensity;
switch (type) {
case "ambient":
ability = AmbientLight;
component = AmbientLight;
props = { name, color, intensity };
break;
case "directional":
ability = DirectLight;
component = DirectLight;
props = { name, color, intensity };
break;
case "point":
ability = PointLight;
component = PointLight;
props = { name, color, intensity };
break;
case "spot":
ability = SpotLight;
component = SpotLight;
props = { name, color, intensity, angle: spot.outerConeAngle };
break;
default:
Logger.error(`unknown light typ ${type}`);
break;
}

if (ability) {
results[i] = { ability, props };
if (component) {
results[i] = { component, props };
}
}
return results;
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/shadow/ShadowFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,20 @@ export class ShadowFeature extends SceneFeature {
const items = renderQueue.items;
for (let i = 0, len = items.length; i < len; i++) {
const item = items[i];
const ability: Component = item.component;
const component: Component = item.component;

const receiveShadow = (ability as any).recieveShadow;
const castShadow = (ability as any).castShadow;
const receiveShadow = (component as any).recieveShadow;
const castShadow = (component as any).castShadow;
if (receiveShadow === true) {
ability.entity.layer |= Layer.Layer30; //SHADOW;
component.entity.layer |= Layer.Layer30; //SHADOW;
} else if (receiveShadow === false) {
ability.entity.layer &= ~Layer.Layer30; //SHADOW;
component.entity.layer &= ~Layer.Layer30; //SHADOW;
}

if (castShadow === true) {
ability.entity.layer |= Layer.Layer31; //SHADOW_MAP;
component.entity.layer |= Layer.Layer31; //SHADOW_MAP;
} else if (castShadow === false) {
ability.entity.layer &= ~Layer.Layer31; //SHADOW_MAP;
component.entity.layer &= ~Layer.Layer31; //SHADOW_MAP;
}
}
}
Expand Down

0 comments on commit 5401e8a

Please sign in to comment.