diff --git a/src/generatedCode.ts b/src/generatedCode.ts index 4199e404..32241ec6 100644 --- a/src/generatedCode.ts +++ b/src/generatedCode.ts @@ -17611,7 +17611,7 @@ export class FiberScenePropsHandler implements PropsHandler; vrExperienceHelper: FiberVRExperienceHelperProps & FiberVRExperienceHelperPropsCtor & BabylonNode; dynamicTerrain: FiberDynamicTerrainProps & FiberDynamicTerrainPropsCtor & BabylonNode; + model: ModelProps & BabylonNode; } } } diff --git a/tools/generate-code.ts b/tools/generate-code.ts index 394a242d..dbcac71e 100644 --- a/tools/generate-code.ts +++ b/tools/generate-code.ts @@ -73,6 +73,19 @@ const addHostElement = (className: string, babylonjsClassDeclaration: ClassDecla } } +const addCustomHostElement = (className: string, type: string): void => { + if (REACT_EXPORTS.has(className)) { + console.error('Found existing export:', className); // would happen in BabylonJS added class with same name + return; + } + + REACT_EXPORTS.add(className); + INTRINSIC_ELEMENTS.addProperty({ + name: classToIntrinsic(className), + type + } as OptionalKind) +} + const monkeyPatchInterfaces: Map = new Map(); const enumMap: Map = new Map(); let ENUMS_LIST: string[] = []; @@ -1142,6 +1155,11 @@ const generateCode = async () => { namedImports: ['CustomProps'] }) + generatedPropsSourceFile.addImportDeclaration({ + moduleSpecifier: './model', + namedImports: ['ModelProps'] + }) + const addMeshMetadata = (newClassDeclaration: ClassDeclaration, metadata: CreatedInstanceMetadata, originalClassDeclaration?: ClassDeclaration) => { metadata.isMesh = (originalClassDeclaration !== undefined && originalClassDeclaration.getName() === "Mesh") } @@ -1274,6 +1292,10 @@ const generateCode = async () => { addPropsAndHandlerClasses(generatedCodeSourceFile, generatedPropsSourceFile, className, sceneClassDeclaration, getInstanceProperties(sceneTuple.classDeclaration), getInstanceSetMethods(sceneTuple.classDeclaration), undefined); } + + // add our own custom components - needed for TypeScript compatibility: + addCustomHostElement('Model', 'ModelProps & BabylonNode'); + addReactExports(generatedCodeSourceFile); generatedCodeSourceFile.addImportDeclaration({