Skip to content

Commit

Permalink
add layer metadata for assigning textures
Browse files Browse the repository at this point in the history
  • Loading branch information
brianzinn committed Nov 11, 2021
1 parent bec3980 commit f15223f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/CreatedInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface InstanceMetadataParameter {
isShadowGenerator?: boolean
isUtilityLayerRenderer?: boolean
isGizmo?: boolean
isLayer?: boolean
}

export interface CreatedInstanceMetadata extends InstanceMetadataParameter {
Expand Down
5 changes: 4 additions & 1 deletion src/customHosts/TexturesLifecycleListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ export default class TexturesLifecycleListener extends BaseLifecycleListener<Tex
let tmp: CreatedInstance<any> | null = instance.parent;

while (tmp !== null) {
if (tmp.metadata && (tmp.metadata.isMaterial === true || tmp.metadata.className === 'Model')) {
if (tmp.metadata && (tmp.metadata.isMaterial === true || tmp.metadata.className === 'Model' || tmp.metadata.isLayer === true)) {
if (assignTo) {
assignProperty(texture, tmp.hostInstance, assignTo);
} else {
if (tmp.metadata.isLayer === true) {
continue;
}
// maybe below case is more common, so let it default
tmp.hostInstance.diffuseTexture = texture;
}
Expand Down
1 change: 1 addition & 0 deletions src/generatedCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16998,6 +16998,7 @@ export class FiberLayer implements HasPropsHandlers<FiberLayerProps> {
]
};
public static readonly Metadata: CreatedInstanceMetadata = {
"isLayer": true,
"className": "FiberLayer"
};
}
Expand Down
2 changes: 1 addition & 1 deletion tools/generate-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ const generateCode = async () => {
createSingleClass("CascadedShadowGenerator", generatedCodeSourceFile, generatedPropsSourceFile, undefined, { delayCreation: true, isShadowGenerator: true }, () => { return; }, 'ShadowGeneratorCustomProps');
createSingleClass("EngineView", generatedCodeSourceFile, generatedPropsSourceFile, undefined, { delayCreation: true }, () => { return; });
createSingleClass("GizmoManager", generatedCodeSourceFile, generatedPropsSourceFile);
createSingleClass("Layer", generatedCodeSourceFile, generatedPropsSourceFile);
createSingleClass("Layer", generatedCodeSourceFile, generatedPropsSourceFile, undefined, { isLayer: true });

console.log('Adding read-only property classes:');
readonlyPropertiesToGenerate.forEach((value: ClassNameSpaceTuple, className: string) => {
Expand Down

0 comments on commit f15223f

Please sign in to comment.