refactor: change loadModel parameter from string to string array

- Update loadModel signature: url: string -> urls: string[]
- Update validation logic for array parameter
- Update all demo files to pass array instead of single string
This commit is contained in:
yuding
2026-02-26 16:03:38 +08:00
parent 191c571f40
commit fdc6f884aa
5 changed files with 15 additions and 15 deletions

View File

@@ -331,7 +331,7 @@ const loadModel = () => {
// 加载模型文件(从 model 目录) // 加载模型文件(从 model 目录)
const modelUrl = 'https://lyz-1259524260.cos.ap-guangzhou.myqcloud.com/iflow/models/8634e556-a94e-4ba7-be3e-2ea1507cced5/'; const modelUrl = 'https://lyz-1259524260.cos.ap-guangzhou.myqcloud.com/iflow/models/8634e556-a94e-4ba7-be3e-2ea1507cced5/';
engine.value.engine.loadModel(modelUrl, { engine.value.engine.loadModel([modelUrl], {
position: [0, 0, 0], // 初始位置 position: [0, 0, 0], // 初始位置
rotation: [0, 0, 0], // 初始旋转 rotation: [0, 0, 0], // 初始旋转
scale: [1, 1, 1] // 初始缩放 scale: [1, 1, 1] // 初始缩放
@@ -361,7 +361,7 @@ const switchModel = () => {
} }
try { try {
engine.value.engine.loadModel(newUrl.trim(), { engine.value.engine.loadModel([newUrl.trim()], {
position: [0, 0, 0], position: [0, 0, 0],
rotation: [0, 0, 0], rotation: [0, 0, 0],
scale: [1, 1, 1] scale: [1, 1, 1]

View File

@@ -398,7 +398,7 @@
// 加载模型文件(从 model 目录) // 加载模型文件(从 model 目录)
const modelUrl = 'https://lyz-1259524260.cos.ap-guangzhou.myqcloud.com/iflow/models/417664a3-76c8-4d94-9344-1337246a5d4e/'; const modelUrl = 'https://lyz-1259524260.cos.ap-guangzhou.myqcloud.com/iflow/models/417664a3-76c8-4d94-9344-1337246a5d4e/';
engine.engine.loadModel(modelUrl, { engine.engine.loadModel([modelUrl], {
position: [0, 0, 0], // 初始位置 position: [0, 0, 0], // 初始位置
rotation: [0, 0, 0], // 初始旋转 rotation: [0, 0, 0], // 初始旋转
scale: [1, 1, 1] // 初始缩放 scale: [1, 1, 1] // 初始缩放
@@ -455,7 +455,7 @@
} }
try { try {
engine.engine.loadModel(newUrl.trim(), { engine.engine.loadModel([newUrl.trim()], {
position: [0, 0, 0], position: [0, 0, 0],
rotation: [0, 0, 0], rotation: [0, 0, 0],
scale: [1, 1, 1] scale: [1, 1, 1]

View File

@@ -129,7 +129,7 @@
// 加载模型文件(从 model 目录)- 使用与 index.html 相同的模型路径 // 加载模型文件(从 model 目录)- 使用与 index.html 相同的模型路径
const modelUrl = 'https://lyz-1259524260.cos.ap-guangzhou.myqcloud.com/iflow/models/8634e556-a94e-4ba7-be3e-2ea1507cced5/'; const modelUrl = 'https://lyz-1259524260.cos.ap-guangzhou.myqcloud.com/iflow/models/8634e556-a94e-4ba7-be3e-2ea1507cced5/';
engine.engine.loadModel(modelUrl, { engine.engine.loadModel([modelUrl], {
position: [0, 0, 0], // 初始位置 position: [0, 0, 0], // 初始位置
rotation: [0, 0, 0], // 初始旋转 rotation: [0, 0, 0], // 初始旋转
scale: [1, 1, 1] // 初始缩放 scale: [1, 1, 1] // 初始缩放

View File

@@ -7,8 +7,8 @@ import type { MeasureUnit, MeasurePrecision } from '../measure-panel/types';
import type { SectionBoxRange } from '../section-box-panel/types'; import type { SectionBoxRange } from '../section-box-panel/types';
import { ManagerRegistry } from '../../core/manager-registry'; import { ManagerRegistry } from '../../core/manager-registry';
// 导入第三方 SDK 的 createEngine 函数(从 npm 包引入) // 导入第三方 SDK 的 createEngine 函数(从 npm 包引入)
// import { createEngine as createEngineSDK } from 'iflow-engine-base'; import { createEngine as createEngineSDK } from 'iflow-engine-base';
import { createEngine as createEngineSDK } from '../../../../bim_engine_base/dist/bim-engine-sdk.es'; //import { createEngine as createEngineSDK } from '../../../../bim_engine_base/dist/bim-engine-sdk.es';
import "../../../../bim_engine_base/dist/iflow-engine-base.css" import "../../../../bim_engine_base/dist/iflow-engine-base.css"
export type { EngineOptions, ModelLoadOptions, EngineInfo }; export type { EngineOptions, ModelLoadOptions, EngineInfo };
@@ -175,19 +175,19 @@ export class Engine implements IBimComponent {
/** /**
* 加载 3D 模型 * 加载 3D 模型
* @param url 模型文件 URL * @param urls 模型文件 URL 数组
* @param options 加载选项(位置、旋转、缩放) * @param options 加载选项(位置、旋转、缩放)
*/ */
public loadModel(url: string, options?: ModelLoadOptions): void { public loadModel(urls: string[], options?: ModelLoadOptions): void {
if (!this._isInitialized || !this.engine) { if (!this._isInitialized || !this.engine) {
console.error('[Engine] Engine not initialized. Please call init() first.'); console.error('[Engine] Engine not initialized. Please call init() first.');
return; return;
} }
if (!url) { if (!urls || urls.length === 0) {
console.error('[Engine] Model URL is required.'); console.error('[Engine] Model URLs are required.');
return; return;
} }
this.engine.loaderModule.loadModels([url], options); this.engine.loaderModule.loadModels(urls, options);
} }
/** /**

View File

@@ -234,15 +234,15 @@ export class EngineManager extends BaseManager {
/** /**
* 加载模型 * 加载模型
* @param url 模型 URL * @param urls 模型 URL 数组
* @param options 加载选项 * @param options 加载选项
*/ */
public loadModel(url: string, options?: ModelLoadOptions): void { public loadModel(urls: string[], options?: ModelLoadOptions): void {
if (!this.engineInstance) { if (!this.engineInstance) {
console.warn('[EngineManager] 3D Engine not initialized.'); console.warn('[EngineManager] 3D Engine not initialized.');
return; return;
} }
this.engineInstance.loadModel(url, options); this.engineInstance.loadModel(urls, options);
} }
/** /**