feat: upgrade iflow-engine-base to v1.0.5, add pause/resume rendering API
- Update iflow-engine-base from 1.0.1 to 1.0.5 - Change default engine version from v1 to v2 - Add pauseRendering() and resumeRendering() methods - Add switch model feature in demos - Update model URLs in demos - Add new documentation files
This commit is contained in:
@@ -173,6 +173,11 @@
|
||||
<div class="btn-container">
|
||||
<button class="primary" onclick="initEngine3D()">初始化引擎</button>
|
||||
<button class="primary" onclick="loadModel()">加载模型</button>
|
||||
<button onclick="switchModel()">切换模型</button>
|
||||
</div>
|
||||
<div class="btn-container" style="margin-top: 8px;">
|
||||
<button onclick="pauseRendering()">暂停渲染</button>
|
||||
<button onclick="resumeRendering()">恢复渲染</button>
|
||||
</div>
|
||||
<div style="margin-top: 10px; font-size: 0.85rem; color: #666;">
|
||||
<div>状态: <span id="engine-status">未初始化</span></div>
|
||||
@@ -345,7 +350,7 @@
|
||||
// 初始化引擎,使用默认配置
|
||||
const success = engine.engine.initialize({
|
||||
backgroundColor: 0x333333, // 深色背景
|
||||
version: 'v1', // WebGL 版本
|
||||
version: 'v2', // WebGL 版本
|
||||
showStats: true, // 显示性能统计
|
||||
showViewCube: true // 显示视图立方体
|
||||
});
|
||||
@@ -381,7 +386,7 @@
|
||||
|
||||
try {
|
||||
// 加载模型文件(从 model 目录)
|
||||
const modelUrl = './model/test2';
|
||||
const modelUrl = 'https://lyz-1259524260.cos.ap-guangzhou.myqcloud.com/iflow/models/8634e556-a94e-4ba7-be3e-2ea1507cced5/';
|
||||
|
||||
engine.engine.loadModel(modelUrl, {
|
||||
position: [0, 0, 0], // 初始位置
|
||||
@@ -395,6 +400,62 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停渲染
|
||||
*/
|
||||
function pauseRendering() {
|
||||
if (!engine || !engine.engine || !engine.engine.isInitialized()) {
|
||||
alert('请先初始化 3D 引擎!');
|
||||
return;
|
||||
}
|
||||
engine.engine.pauseRendering();
|
||||
console.log('✅ 渲染已暂停');
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复渲染
|
||||
*/
|
||||
function resumeRendering() {
|
||||
if (!engine || !engine.engine || !engine.engine.isInitialized()) {
|
||||
alert('请先初始化 3D 引擎!');
|
||||
return;
|
||||
}
|
||||
engine.engine.resumeRendering();
|
||||
console.log('✅ 渲染已恢复');
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换模型 - 输入新的模型 URL
|
||||
*/
|
||||
function switchModel() {
|
||||
if (!engine || !engine.engine) {
|
||||
alert('引擎未创建,请先等待页面加载完成');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!engine.engine.isInitialized()) {
|
||||
alert('请先初始化 3D 引擎!');
|
||||
return;
|
||||
}
|
||||
|
||||
const newUrl = prompt('请输入新的模型 URL:', 'https://lyz-1259524260.cos.ap-guangzhou.myqcloud.com/iflow/models/8634e556-a94e-4ba7-be3e-2ea1507cced5/');
|
||||
|
||||
if (!newUrl || newUrl.trim() === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
engine.engine.loadModel(newUrl.trim(), {
|
||||
position: [0, 0, 0],
|
||||
rotation: [0, 0, 0],
|
||||
scale: [1, 1, 1]
|
||||
});
|
||||
console.log('✅ 切换模型请求已发送:', newUrl);
|
||||
} catch (error) {
|
||||
console.error('❌ 切换模型错误:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开属性面板
|
||||
*/
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
|
||||
try {
|
||||
// 加载模型文件(从 model 目录)- 使用与 index.html 相同的模型路径
|
||||
const modelUrl = './model/test2';
|
||||
const modelUrl = 'https://lyz-1259524260.cos.ap-guangzhou.myqcloud.com/iflow/models/8634e556-a94e-4ba7-be3e-2ea1507cced5/';
|
||||
|
||||
engine.engine.loadModel(modelUrl, {
|
||||
position: [0, 0, 0], // 初始位置
|
||||
|
||||
Reference in New Issue
Block a user