Skip to content

Commit f9ca23c

Browse files
bghgaryCopilot
andcommitted
Expose Texture::NumLayers via NativeEngine.getTextureLayerCount
Babylon.js side wraps native textures with engine.wrapNativeTexture and sets InternalTexture properties from the engine bindings. Today the binding only exposes width and height, so consumers cannot detect that a wrapped texture is a Texture2DArray and InternalTexture.is2DArray / .depth stay at their defaults. Add getTextureLayerCount returning Texture::NumLayers so Babylon.js can populate is2DArray and depth on the wrapped InternalTexture automatically, without the host having to thread the layer count through its own bridge. [Created by Copilot on behalf of @bghgary] Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8df2d91 commit f9ca23c

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

Plugins/NativeEngine/Source/NativeEngine.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ namespace Babylon
716716
InstanceMethod("loadCubeTextureWithMips", &NativeEngine::LoadCubeTextureWithMips),
717717
InstanceMethod("getTextureWidth", &NativeEngine::GetTextureWidth),
718718
InstanceMethod("getTextureHeight", &NativeEngine::GetTextureHeight),
719+
InstanceMethod("getTextureLayerCount", &NativeEngine::GetTextureLayerCount),
719720
InstanceMethod("deleteTexture", &NativeEngine::DeleteTexture),
720721
InstanceMethod("readTexture", &NativeEngine::ReadTexture),
721722

@@ -1541,6 +1542,12 @@ namespace Babylon
15411542
return Napi::Value::From(info.Env(), texture->Height());
15421543
}
15431544

1545+
Napi::Value NativeEngine::GetTextureLayerCount(const Napi::CallbackInfo& info)
1546+
{
1547+
const Graphics::Texture* texture = info[0].As<Napi::Pointer<Graphics::Texture>>().Get();
1548+
return Napi::Value::From(info.Env(), texture->NumLayers());
1549+
}
1550+
15441551
void NativeEngine::SetTextureSampling(NativeDataStream::Reader& data)
15451552
{
15461553
auto& texture = *data.ReadPointer<Graphics::Texture>();

Plugins/NativeEngine/Source/NativeEngine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ namespace Babylon
9797
void LoadCubeTextureWithMips(const Napi::CallbackInfo& info);
9898
Napi::Value GetTextureWidth(const Napi::CallbackInfo& info);
9999
Napi::Value GetTextureHeight(const Napi::CallbackInfo& info);
100+
Napi::Value GetTextureLayerCount(const Napi::CallbackInfo& info);
100101
void SetTextureSampling(NativeDataStream::Reader& data);
101102
void SetTextureWrapMode(NativeDataStream::Reader& data);
102103
void SetTextureAnisotropicLevel(NativeDataStream::Reader& data);

0 commit comments

Comments
 (0)