feat(wasm): Disable 3D viewer with comprehensive stubs

- Set KICAD_BUILD_3D_VIEWER_WASM=OFF in build script
- Add comprehensive 3D canvas stubs (~500 lines) including:
  - EDA_3D_CANVAS with wxWidgets event table
  - BOARD_ADAPTER, EDA_3D_VIEWER_SETTINGS
  - PANEL_PREVIEW_3D_MODEL with all event handlers
  - DIALOG_SELECT_3DMODEL
  - TRACK_BALL camera
  - BBOX_2D, BBOX_3D, BVH_CONTAINER_2D
  - OGL_ATT_LIST::GetAttributesList
- Add 3D scenegraph stubs for VRML export
- Update KiCad submodule with WASM guards
- Update WebGL GAL implementation plan to COMPLETE status

All 4 phases of the WebGL GAL implementation are now complete:
- Phase 1: Native test harness (28 scenarios)
- Phase 2: WebGL GAL implementation (~27,800 lines)
- Phase 3: Complete API coverage
- Phase 4: KiCad integration with 3D viewer stubs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2026-01-10 15:15:50 +01:00
commit 71d2444729
6 changed files with 830 additions and 101 deletions

View file

@ -9,15 +9,25 @@
#include <3d_viewer/eda_3d_viewer_settings.h>
#include <gal/hidpi_gl_3D_canvas.h>
#include <tool/tool_dispatcher.h>
#include <view/view_controls.h>
#include <dialogs/panel_preview_3d_model.h>
#include <dialogs/dialog_select_3d_model.h>
#include <3d_rendering/track_ball.h>
#include <common_ogl/ogl_attr_list.h>
// EDA_3D_CANVAS event table stub
BEGIN_EVENT_TABLE( EDA_3D_CANVAS, HIDPI_GL_3D_CANVAS )
END_EVENT_TABLE()
// EDA_3D_CANVAS stub implementations
EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const wxGLAttributes& aGLAttribs,
BOARD_ADAPTER& aSettings, CAMERA& aCamera,
S3D_CACHE* a3DCachePointer ) :
HIDPI_GL_3D_CANVAS( aParent, aGLAttribs, aCamera, wxID_ANY )
HIDPI_GL_3D_CANVAS( KIGFX::VC_SETTINGS(), aCamera, aParent, aGLAttribs,
wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE ),
m_boardAdapter( aSettings )
{
(void)aSettings;
(void)a3DCachePointer;
m_3d_render = nullptr;
m_parentStatusBar = nullptr;
@ -52,12 +62,6 @@ void EDA_3D_CANVAS::DoRePaint()
// No-op: 3D canvas not available in WASM
}
void EDA_3D_CANVAS::SetCurrentRender( RENDER_ENGINE aRenderEngine )
{
(void)aRenderEngine;
// No-op: 3D canvas not available in WASM
}
void EDA_3D_CANVAS::RenderEngineChanged()
{
// No-op: 3D canvas not available in WASM
@ -74,11 +78,6 @@ void EDA_3D_CANVAS::DisplayStatus()
// No-op: 3D canvas not available in WASM
}
bool EDA_3D_CANVAS::doReRender()
{
return false;
}
// BOARD_ADAPTER stub implementations
@ -101,8 +100,10 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() :
{
}
EDA_3D_VIEWER_SETTINGS::~EDA_3D_VIEWER_SETTINGS()
bool EDA_3D_VIEWER_SETTINGS::MigrateFromLegacy( wxConfigBase* aLegacyConfig )
{
(void)aLegacyConfig;
return true;
}
@ -134,3 +135,365 @@ void PARAM_LAYER_PRESET_3D::jsonToPresets( const nlohmann::json& aJson )
{
(void)aJson;
}
// PANEL_PREVIEW_3D_MODEL stub implementations
// Required for footprint properties 3D model panel
wxDEFINE_EVENT( wxCUSTOM_PANEL_SHOWN_EVENT, wxCommandEvent );
PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
FOOTPRINT* aFootprint,
std::vector<FP_3DMODEL>* aParentModelList ) :
TOOLS_HOLDER(),
PANEL_PREVIEW_3D_MODEL_BASE( aParent ),
m_parentFrame( aFrame ),
m_previewPane( nullptr ),
m_infobar( nullptr ),
m_boardAdapter(),
m_currentCamera( m_trackBallCamera ),
m_trackBallCamera( 2 * RANGE_SCALE_3D ),
m_dummyBoard( nullptr ),
m_dummyFootprint( nullptr ),
m_parentModelList( aParentModelList ),
m_selected( -1 ),
m_userUnits( EDA_UNITS::MM )
{
(void)aFootprint;
// 3D preview not supported in WASM
}
PANEL_PREVIEW_3D_MODEL::~PANEL_PREVIEW_3D_MODEL()
{
}
void PANEL_PREVIEW_3D_MODEL::OnMenuEvent( wxMenuEvent& aEvent )
{
(void)aEvent;
}
void PANEL_PREVIEW_3D_MODEL::SetSelectedModel( int idx )
{
(void)idx;
// No-op: 3D preview not available in WASM
}
void PANEL_PREVIEW_3D_MODEL::UpdateDummyFootprint( bool aReloadRequired )
{
(void)aReloadRequired;
// No-op: 3D preview not available in WASM
}
void PANEL_PREVIEW_3D_MODEL::SetEmbeddedFilesDelegate( EMBEDDED_FILES* aDelegate )
{
(void)aDelegate;
// No-op: 3D preview not available in WASM
}
// DIALOG_SELECT_3DMODEL stub implementations
DIALOG_SELECT_3DMODEL::DIALOG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager,
FP_3DMODEL* aModelItem, wxString& prevModelSelectDir,
int& prevModelWildcard ) :
DIALOG_SELECT_3D_MODEL_BASE( aParent ),
m_model( aModelItem ),
m_cache( aCacheManager ),
m_resolver( nullptr ),
m_previousDir( prevModelSelectDir ),
m_modelViewer( nullptr )
{
(void)prevModelWildcard;
// 3D model selection not supported in WASM
}
bool DIALOG_SELECT_3DMODEL::TransferDataFromWindow()
{
return true;
}
void DIALOG_SELECT_3DMODEL::OnSelectionChanged( wxCommandEvent& event )
{
(void)event;
}
void DIALOG_SELECT_3DMODEL::OnFileActivated( wxCommandEvent& event )
{
(void)event;
}
void DIALOG_SELECT_3DMODEL::SetRootDir( wxCommandEvent& event )
{
(void)event;
}
void DIALOG_SELECT_3DMODEL::Cfg3DPaths( wxCommandEvent& event )
{
(void)event;
}
void DIALOG_SELECT_3DMODEL::updateDirChoiceList()
{
}
// DIALOG_SELECT_3D_MODEL_BASE stub implementations
DIALOG_SELECT_3D_MODEL_BASE::~DIALOG_SELECT_3D_MODEL_BASE()
{
}
// TRACK_BALL stub implementations
TRACK_BALL::TRACK_BALL( float aInitialDistance ) : CAMERA( aInitialDistance )
{
initQuat();
}
TRACK_BALL::TRACK_BALL( SFVEC3F aInitPos, SFVEC3F aLookat, PROJECTION_TYPE aProjectionType )
: CAMERA( aInitPos, aLookat, aProjectionType )
{
initQuat();
}
void TRACK_BALL::initQuat()
{
m_quat_t0[0] = m_quat_t0[1] = m_quat_t0[2] = 0.0;
m_quat_t0[3] = 1.0;
m_quat_t1[0] = m_quat_t1[1] = m_quat_t1[2] = 0.0;
m_quat_t1[3] = 1.0;
}
void TRACK_BALL::Drag( const wxPoint& aNewMousePosition )
{
(void)aNewMousePosition;
}
void TRACK_BALL::Pan( const wxPoint& aNewMousePosition )
{
(void)aNewMousePosition;
}
void TRACK_BALL::Pan( const SFVEC3F& aDeltaOffsetInc )
{
(void)aDeltaOffsetInc;
}
void TRACK_BALL::Pan_T1( const SFVEC3F& aDeltaOffsetInc )
{
(void)aDeltaOffsetInc;
}
void TRACK_BALL::Reset_T1()
{
}
void TRACK_BALL::SetT0_and_T1_current_T()
{
}
void TRACK_BALL::Interpolate( float t )
{
(void)t;
}
// EDA_3D_CANVAS additional method stubs
void EDA_3D_CANVAS::OnCloseWindow( wxCloseEvent& event )
{
(void)event;
}
// OGL_ATT_LIST stub implementations
const wxGLAttributes OGL_ATT_LIST::GetAttributesList( ANTIALIASING_MODE aAntiAliasingMode, bool aUseDepth )
{
(void)aAntiAliasingMode;
(void)aUseDepth;
wxGLAttributes glAttribs;
glAttribs.PlatformDefaults().RGBA().DoubleBuffer().EndList();
return glAttribs;
}
// BBOX_3D stub implementations
#include <3d_rendering/raytracing/shapes3D/bbox_3d.h>
BBOX_3D::BBOX_3D()
{
m_min = SFVEC3F( 0.0f, 0.0f, 0.0f );
m_max = SFVEC3F( 0.0f, 0.0f, 0.0f );
}
BBOX_3D::BBOX_3D( const SFVEC3F& aPbInit ) : m_min( aPbInit ), m_max( aPbInit )
{
}
BBOX_3D::BBOX_3D( const SFVEC3F& aPbMin, const SFVEC3F& aPbMax ) : m_min( aPbMin ), m_max( aPbMax )
{
}
BBOX_3D::~BBOX_3D()
{
}
// BVH_CONTAINER_2D and base class stub implementations
#include <3d_rendering/raytracing/accelerators/container_2d.h>
CONTAINER_2D_BASE::CONTAINER_2D_BASE( OBJECT_2D_TYPE aObjType )
{
(void)aObjType;
}
CONTAINER_2D_BASE::~CONTAINER_2D_BASE()
{
}
void CONTAINER_2D_BASE::Clear()
{
}
BVH_CONTAINER_2D::BVH_CONTAINER_2D() : CONTAINER_2D_BASE( OBJECT_2D_TYPE::FILLED_CIRCLE )
{
m_isInitialized = false;
m_tree = nullptr;
m_elementsToDelete.clear();
}
BVH_CONTAINER_2D::~BVH_CONTAINER_2D()
{
}
void BVH_CONTAINER_2D::BuildBVH()
{
}
void BVH_CONTAINER_2D::Clear()
{
}
void BVH_CONTAINER_2D::GetIntersectingObjects( const BBOX_2D& aBBox, CONST_LIST_OBJECT2D& aOutList ) const
{
(void)aBBox;
(void)aOutList;
}
bool BVH_CONTAINER_2D::IntersectAny( const RAYSEG2D& aSegRay ) const
{
(void)aSegRay;
return false;
}
// PANEL_PREVIEW_3D_MODEL_BASE stub implementations
#include <dialogs/panel_preview_3d_model_base.h>
PANEL_PREVIEW_3D_MODEL_BASE::PANEL_PREVIEW_3D_MODEL_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name )
: wxPanel( parent, id, pos, size, style, name )
{
}
PANEL_PREVIEW_3D_MODEL_BASE::~PANEL_PREVIEW_3D_MODEL_BASE()
{
}
// PANEL_PREVIEW_3D_MODEL additional stub implementations
void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& event, double rotationIncrement )
{
(void)event;
(void)rotationIncrement;
}
void PANEL_PREVIEW_3D_MODEL::doIncrementScale( wxSpinEvent& event, double scaleIncrement )
{
(void)event;
(void)scaleIncrement;
}
void PANEL_PREVIEW_3D_MODEL::doIncrementOffset( wxSpinEvent& event, double offsetIncrement )
{
(void)event;
(void)offsetIncrement;
}
void PANEL_PREVIEW_3D_MODEL::updateOrientation( wxCommandEvent& event )
{
(void)event;
}
void PANEL_PREVIEW_3D_MODEL::onMouseWheelScale( wxMouseEvent& event )
{
(void)event;
}
void PANEL_PREVIEW_3D_MODEL::onMouseWheelRot( wxMouseEvent& event )
{
(void)event;
}
void PANEL_PREVIEW_3D_MODEL::onMouseWheelOffset( wxMouseEvent& event )
{
(void)event;
}
void PANEL_PREVIEW_3D_MODEL::onOpacitySlider( wxCommandEvent& event )
{
(void)event;
}
void PANEL_PREVIEW_3D_MODEL::setBodyStyleView( wxCommandEvent& event )
{
(void)event;
}
void PANEL_PREVIEW_3D_MODEL::View3DSettings( wxCommandEvent& event )
{
(void)event;
}
// EDA_3D_CANVAS additional stub implementations
bool EDA_3D_CANVAS::SetView3D( VIEW3D_TYPE aViewType )
{
(void)aViewType;
return false;
}
// BBOX_2D stub implementations
#include <3d_rendering/raytracing/shapes2D/bbox_2d.h>
BBOX_2D::BBOX_2D()
{
m_min = SFVEC2F( 0.0f, 0.0f );
m_max = SFVEC2F( 0.0f, 0.0f );
}
BBOX_2D::BBOX_2D( const SFVEC2F& aPbMin, const SFVEC2F& aPbMax ) : m_min( aPbMin ), m_max( aPbMax )
{
}
BBOX_2D::~BBOX_2D()
{
}
// DIALOG_SELECT_3D_MODEL_BASE stub implementations
#include <dialogs/dialog_select_3d_model_base.h>
DIALOG_SELECT_3D_MODEL_BASE::DIALOG_SELECT_3D_MODEL_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style )
: DIALOG_SHIM( parent, id, title, pos, size, style )
{
}

View file

@ -6,7 +6,9 @@
#include <3d_cache/3d_cache.h>
#include <3d_cache/3d_plugin_manager.h>
#include <plugins/3dapi/ifsg_all.h>
#include <wx/log.h>
#include <cmath>
// S3D_CACHE stub implementations
@ -125,3 +127,314 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, const wxString& aBasePa
*aCachePtr = nullptr;
return nullptr;
}
// SGPOINT stub implementations
SGPOINT::SGPOINT() : x( 0.0 ), y( 0.0 ), z( 0.0 )
{
}
SGPOINT::SGPOINT( double aXVal, double aYVal, double aZVal ) noexcept
: x( aXVal ), y( aYVal ), z( aZVal )
{
}
void SGPOINT::GetPoint( const double& aXVal, const double& aYVal, const double& aZVal ) noexcept
{
(void)aXVal; (void)aYVal; (void)aZVal;
}
void SGPOINT::GetPoint( const SGPOINT& aPoint ) noexcept
{
(void)aPoint;
}
void SGPOINT::GetPoint( const SGPOINT* aPoint ) noexcept
{
(void)aPoint;
}
void SGPOINT::SetPoint( double aXVal, double aYVal, double aZVal ) noexcept
{
x = aXVal; y = aYVal; z = aZVal;
}
void SGPOINT::SetPoint( const SGPOINT& aPoint ) noexcept
{
x = aPoint.x; y = aPoint.y; z = aPoint.z;
}
// SGVECTOR stub implementations
SGVECTOR::SGVECTOR() : vx( 0.0 ), vy( 0.0 ), vz( 1.0 )
{
}
SGVECTOR::SGVECTOR( double aXVal, double aYVal, double aZVal )
: vx( aXVal ), vy( aYVal ), vz( aZVal )
{
normalize();
}
void SGVECTOR::GetVector( double& aXVal, double& aYVal, double& aZVal ) const noexcept
{
aXVal = vx; aYVal = vy; aZVal = vz;
}
void SGVECTOR::SetVector( double aXVal, double aYVal, double aZVal )
{
vx = aXVal; vy = aYVal; vz = aZVal;
normalize();
}
void SGVECTOR::SetVector( const SGVECTOR& aVector )
{
vx = aVector.vx; vy = aVector.vy; vz = aVector.vz;
}
SGVECTOR& SGVECTOR::operator=( const SGVECTOR& source ) noexcept
{
vx = source.vx; vy = source.vy; vz = source.vz;
return *this;
}
void SGVECTOR::normalize() noexcept
{
double mag = vx*vx + vy*vy + vz*vz;
if( mag > 1e-12 )
{
mag = 1.0 / sqrt( mag );
vx *= mag; vy *= mag; vz *= mag;
}
}
// SGCOLOR stub implementations
SGCOLOR::SGCOLOR() : red( 0.0f ), green( 0.0f ), blue( 0.0f )
{
}
SGCOLOR::SGCOLOR( float aRVal, float aGVal, float aBVal )
: red( aRVal ), green( aGVal ), blue( aBVal )
{
}
void SGCOLOR::GetColor( float& aRedVal, float& aGreenVal, float& aBlueVal ) const noexcept
{
aRedVal = red; aGreenVal = green; aBlueVal = blue;
}
void SGCOLOR::GetColor( SGCOLOR& aColor ) const noexcept
{
aColor.red = red; aColor.green = green; aColor.blue = blue;
}
void SGCOLOR::GetColor( SGCOLOR* aColor ) const noexcept
{
if( aColor ) { aColor->red = red; aColor->green = green; aColor->blue = blue; }
}
bool SGCOLOR::SetColor( float aRedVal, float aGreenVal, float aBlueVal )
{
red = aRedVal; green = aGreenVal; blue = aBlueVal;
return true;
}
bool SGCOLOR::SetColor( const SGCOLOR& aColor ) noexcept
{
red = aColor.red; green = aColor.green; blue = aColor.blue;
return true;
}
bool SGCOLOR::SetColor( const SGCOLOR* aColor ) noexcept
{
if( aColor ) { red = aColor->red; green = aColor->green; blue = aColor->blue; return true; }
return false;
}
bool SGCOLOR::checkRange( float aRedVal, float aGreenVal, float aBlueVal ) const noexcept
{
(void)aRedVal; (void)aGreenVal; (void)aBlueVal;
return true;
}
// IFSG_NODE stub implementations
IFSG_NODE::IFSG_NODE() : m_node( nullptr )
{
}
IFSG_NODE::~IFSG_NODE()
{
}
void IFSG_NODE::Destroy()
{
m_node = nullptr;
}
SGNODE* IFSG_NODE::GetRawPtr() noexcept
{
return m_node;
}
S3D::SGTYPES IFSG_NODE::GetNodeType() const
{
return S3D::SGTYPE_TRANSFORM;
}
SGNODE* IFSG_NODE::GetParent() const
{
return nullptr;
}
bool IFSG_NODE::SetParent( SGNODE* aParent )
{
(void)aParent;
return false;
}
const char* IFSG_NODE::GetName()
{
return nullptr;
}
bool IFSG_NODE::SetName( const char* aName )
{
(void)aName;
return false;
}
const char* IFSG_NODE::GetNodeTypeName( S3D::SGTYPES aNodeType ) const
{
(void)aNodeType;
return "STUB";
}
SGNODE* IFSG_NODE::FindNode( const char* aNodeName )
{
(void)aNodeName;
return nullptr;
}
bool IFSG_NODE::AddRefNode( SGNODE* aNode )
{
(void)aNode;
return false;
}
bool IFSG_NODE::AddRefNode( IFSG_NODE& aNode )
{
(void)aNode;
return false;
}
bool IFSG_NODE::AddChildNode( SGNODE* aNode )
{
(void)aNode;
return false;
}
bool IFSG_NODE::AddChildNode( IFSG_NODE& aNode )
{
(void)aNode;
return false;
}
// IFSG_TRANSFORM stub implementations
IFSG_TRANSFORM::IFSG_TRANSFORM( bool create ) : IFSG_NODE()
{
(void)create;
}
IFSG_TRANSFORM::IFSG_TRANSFORM( SGNODE* aParent ) : IFSG_NODE()
{
(void)aParent;
}
bool IFSG_TRANSFORM::Attach( SGNODE* aNode )
{
(void)aNode;
return false;
}
bool IFSG_TRANSFORM::NewNode( SGNODE* aParent )
{
(void)aParent;
return false;
}
bool IFSG_TRANSFORM::NewNode( IFSG_NODE& aParent )
{
(void)aParent;
return false;
}
bool IFSG_TRANSFORM::SetScaleOrientation( const SGVECTOR& aScaleAxis, double aAngle )
{
(void)aScaleAxis; (void)aAngle;
return false;
}
bool IFSG_TRANSFORM::SetRotation( const SGVECTOR& aRotationAxis, double aAngle )
{
(void)aRotationAxis; (void)aAngle;
return false;
}
bool IFSG_TRANSFORM::SetScale( const SGPOINT& aScale ) noexcept
{
(void)aScale;
return false;
}
bool IFSG_TRANSFORM::SetScale( double aScale )
{
(void)aScale;
return false;
}
bool IFSG_TRANSFORM::SetCenter( const SGPOINT& aCenter ) noexcept
{
(void)aCenter;
return false;
}
bool IFSG_TRANSFORM::SetTranslation( const SGPOINT& aTranslation ) noexcept
{
(void)aTranslation;
return false;
}
// S3D namespace stub implementations
namespace S3D
{
bool WriteVRML( const char* filename, bool overwrite, SGNODE* aTopNode,
bool reuse, bool renameNodes )
{
(void)filename; (void)overwrite; (void)aTopNode;
(void)reuse; (void)renameNodes;
return false;
}
SGNODE* GetSGNodeParent( SGNODE* aNode )
{
(void)aNode;
return nullptr;
}
void DestroyNode( SGNODE* aNode ) noexcept
{
(void)aNode;
}
} // namespace S3D

View file

@ -7,6 +7,7 @@
#include <3d_viewer/eda_3d_viewer_frame.h>
#include <3d_viewer/eda_3d_viewer_settings.h>
#include <3d_viewer/toolbars_3d.h>
#include <base_units.h>
// EDA_3D_VIEWER_FRAME stub implementations
// The 3D viewer is not available in WASM builds
@ -14,7 +15,7 @@
EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent,
const wxString& aTitle, long style ) :
KIWAY_PLAYER( aKiway, aParent, FRAME_PCB_DISPLAY3D, aTitle, wxDefaultPosition,
wxDefaultSize, style, wxT( "3D Viewer" ) ),
wxDefaultSize, style, wxT( "3D Viewer" ), unityScale ),
m_currentCamera( m_trackBallCamera ),
m_trackBallCamera( 2 * RANGE_SCALE_3D )
{