From 7f71a050c8ae0facbed1312f8bd1f1814740061a Mon Sep 17 00:00:00 2001 From: ycw Date: Fri, 30 Jan 2026 19:48:34 +0800 Subject: [PATCH 1/2] Editor: fix app publishing for project using WebGPURenderer (#32897) --- editor/js/Sidebar.Project.App.js | 54 ++++++++++++++++++++++++++++++-- editor/js/libs/app/index.html | 9 +----- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/editor/js/Sidebar.Project.App.js b/editor/js/Sidebar.Project.App.js index e2517530570081..7abf1d944f9c0b 100644 --- a/editor/js/Sidebar.Project.App.js +++ b/editor/js/Sidebar.Project.App.js @@ -85,6 +85,8 @@ function SidebarProjectApp( editor ) { const toZip = {}; + const rendererType = config.getKey( 'project/renderer/type' ); + // let output = editor.toJSON(); @@ -115,6 +117,26 @@ function SidebarProjectApp( editor ) { content = content.replace( '', title ); + // + + const IMPORTMAP = { + WebGLRenderer: { + imports: { + 'three': './js/three.module.js' + } + }, + WebGPURenderer: { + imports: { + 'three': './js/three.webgpu.js', + 'three/webgpu': './js/three.webgpu.js' + } + } + }; + const importmap = JSON.stringify( IMPORTMAP[ rendererType ], null, '\t' ); + content = content.replace( '', indent( '\n' + indent( importmap, 1 ) + '\n', 2 ) ); + + // + let editButton = ''; if ( config.getKey( 'project/editable' ) ) { @@ -145,11 +167,24 @@ function SidebarProjectApp( editor ) { toZip[ 'js/three.core.js' ] = strToU8( content ); } ); - loader.load( '../build/three.module.js', function ( content ) { - toZip[ 'js/three.module.js' ] = strToU8( content ); + if ( rendererType === 'WebGPURenderer' ) { - } ); + loader.load( '../build/three.webgpu.js', function ( content ) { + + toZip[ 'js/three.webgpu.js' ] = strToU8( content ); + + } ); + + } else { + + loader.load( '../build/three.module.js', function ( content ) { + + toZip[ 'js/three.module.js' ] = strToU8( content ); + + } ); + + } } ); container.add( publishButton ); @@ -167,4 +202,17 @@ function SidebarProjectApp( editor ) { } +// + +function indent( text, count, space = '\t' ) { + + return text + .split( '\n' ) + .map( line => space.repeat( count ) + line ) + .join( '\n' ); + +} + +// + export { SidebarProjectApp }; diff --git a/editor/js/libs/app/index.html b/editor/js/libs/app/index.html index e8da53802e31ac..7d27aa54a547a9 100644 --- a/editor/js/libs/app/index.html +++ b/editor/js/libs/app/index.html @@ -18,14 +18,7 @@ - +