feat(3d): FBX/GLTF/OBJ 加载器与骨骼动画支持 (#315)
* feat(3d): FBX/GLTF/OBJ 加载器与骨骼动画支持 * chore: 更新 pnpm-lock.yaml * fix: 移除未使用的变量和方法 * fix: 修复 mesh-3d-editor tsconfig 引用路径 * fix: 修复正则表达式 ReDoS 漏洞
This commit is contained in:
@@ -1541,6 +1541,60 @@ export class EngineBridge implements ITextureEngineBridge, ITextureService, IDyn
|
||||
this.getEngine().render3D();
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit a 3D mesh for rendering (with normals).
|
||||
* 提交 3D 网格进行渲染(包含法线)。
|
||||
*
|
||||
* The mesh will be rendered when render3D() or render() is called.
|
||||
* 网格将在调用 render3D() 或 render() 时渲染。
|
||||
*
|
||||
* @param vertices - Interleaved vertex data Float32Array:
|
||||
* [x, y, z, u, v, r, g, b, a, nx, ny, nz] per vertex (12 floats)
|
||||
* 交错顶点数据:每个顶点 12 个浮点数
|
||||
* @param indices - Triangle indices Uint32Array | 三角形索引
|
||||
* @param transform - 4x4 model transform matrix (column-major, 16 floats)
|
||||
* 4x4 模型变换矩阵(列优先,16 个浮点数)
|
||||
* @param materialId - Material ID (0 for default) | 材质 ID(0 为默认)
|
||||
* @param textureId - Texture ID (0 for white) | 纹理 ID(0 为白色)
|
||||
*/
|
||||
submitMesh3D(
|
||||
vertices: Float32Array,
|
||||
indices: Uint32Array,
|
||||
transform: Float32Array,
|
||||
materialId: number,
|
||||
textureId: number
|
||||
): void {
|
||||
if (!this.initialized) return;
|
||||
this.getEngine().submitMesh3D(vertices, indices, transform, materialId, textureId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit a simplified 3D mesh (without normals).
|
||||
* 提交简化的 3D 网格(无法线)。
|
||||
*
|
||||
* This is more efficient for meshes that don't need lighting calculations.
|
||||
* 对于不需要光照计算的网格,这更高效。
|
||||
*
|
||||
* @param vertices - Interleaved vertex data Float32Array:
|
||||
* [x, y, z, u, v, r, g, b, a] per vertex (9 floats)
|
||||
* 交错顶点数据:每个顶点 9 个浮点数
|
||||
* @param indices - Triangle indices Uint32Array | 三角形索引
|
||||
* @param transform - 4x4 model transform matrix (column-major, 16 floats)
|
||||
* 4x4 模型变换矩阵(列优先,16 个浮点数)
|
||||
* @param materialId - Material ID (0 for default) | 材质 ID(0 为默认)
|
||||
* @param textureId - Texture ID (0 for white) | 纹理 ID(0 为白色)
|
||||
*/
|
||||
submitSimpleMesh3D(
|
||||
vertices: Float32Array,
|
||||
indices: Uint32Array,
|
||||
transform: Float32Array,
|
||||
materialId: number,
|
||||
textureId: number
|
||||
): void {
|
||||
if (!this.initialized) return;
|
||||
this.getEngine().submitSimpleMesh3D(vertices, indices, transform, materialId, textureId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose the bridge and release resources.
|
||||
* 销毁桥接并释放资源。
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
export {
|
||||
RenderSystemToken,
|
||||
EngineIntegrationToken,
|
||||
EngineBridgeToken,
|
||||
// 新的单一职责服务令牌 | New single-responsibility service tokens
|
||||
TextureServiceToken,
|
||||
DynamicAtlasServiceToken,
|
||||
|
||||
@@ -54,3 +54,8 @@ export interface IEngineIntegration {
|
||||
|
||||
export const RenderSystemToken = createServiceToken<IRenderSystem>('renderSystem');
|
||||
export const EngineIntegrationToken = createServiceToken<IEngineIntegration>('engineIntegration');
|
||||
|
||||
// EngineBridge token - used by systems that need direct engine access
|
||||
// EngineBridge 令牌 - 供需要直接访问引擎的系统使用
|
||||
import type { EngineBridge } from './core/EngineBridge';
|
||||
export const EngineBridgeToken = createServiceToken<EngineBridge>('engineBridge');
|
||||
|
||||
@@ -669,6 +669,28 @@ export class GameEngine {
|
||||
* 获取画布高度。
|
||||
*/
|
||||
readonly height: number;
|
||||
/**
|
||||
* Submit a 3D mesh for rendering.
|
||||
* 提交 3D 网格进行渲染。
|
||||
*
|
||||
* @param vertices - Interleaved vertex data [x,y,z, u,v, r,g,b,a, nx,ny,nz] * count
|
||||
* @param indices - Triangle indices
|
||||
* @param transform - 4x4 transformation matrix (column-major)
|
||||
* @param material_id - Material ID
|
||||
* @param texture_id - Texture ID
|
||||
*/
|
||||
submitMesh3D(vertices: Float32Array, indices: Uint32Array, transform: Float32Array, material_id: number, texture_id: number): void;
|
||||
/**
|
||||
* Submit a simple 3D mesh for rendering (without normals).
|
||||
* 提交简单 3D 网格进行渲染(不含法线)。
|
||||
*
|
||||
* @param vertices - Interleaved vertex data [x,y,z, u,v, r,g,b,a] * count
|
||||
* @param indices - Triangle indices
|
||||
* @param transform - 4x4 transformation matrix (column-major)
|
||||
* @param material_id - Material ID
|
||||
* @param texture_id - Texture ID
|
||||
*/
|
||||
submitSimpleMesh3D(vertices: Float32Array, indices: Uint32Array, transform: Float32Array, material_id: number, texture_id: number): void;
|
||||
}
|
||||
|
||||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
||||
|
||||
Reference in New Issue
Block a user