bc-model-viewer 1.7.14 → 1.7.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bc-model-viewer.min.js +1 -1
- package/examples/AreaMeasureTool.html +19 -26
- package/examples/BasicModelLoad.html +66 -0
- package/examples/ChangeStyleDemo.html +3 -74
- package/examples/DistanceMeasureTool.html +19 -26
- package/examples/ExplosionDiagram.html +16 -21
- package/examples/FaceDistanceMeasureTool.html +19 -26
- package/examples/HUDLabelTool.html +19 -35
- package/examples/ModelClipperTool.html +15 -23
- package/examples/PositionCameraTool.html +12 -21
- package/examples/ScenePageDemo.html +20 -49
- package/examples/SelectionZoomTool.html +12 -22
- package/examples/common-styles.css +173 -0
- package/examples/index.html +663 -36
- package/package.json +1 -1
- package/examples/ScenePageDemo.vue +0 -246
- package/examples/ScenePageDemoVue.html +0 -22
package/package.json
CHANGED
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="scene-page-demo">
|
|
3
|
-
<div id="container"></div>
|
|
4
|
-
<div class="control-panel">
|
|
5
|
-
<h2>场景页面管理器演示</h2>
|
|
6
|
-
<div class="scene-buttons" id="modelScenesContainer">
|
|
7
|
-
<button
|
|
8
|
-
v-for="(scene, index) in modelScenes"
|
|
9
|
-
:key="scene.name"
|
|
10
|
-
@click="activateScene(scene)"
|
|
11
|
-
>
|
|
12
|
-
场景 {{ index + 1 }}: {{ scene.name }}
|
|
13
|
-
</button>
|
|
14
|
-
<p v-if="modelScenes.length === 0">模型中未发现场景</p>
|
|
15
|
-
</div>
|
|
16
|
-
<div
|
|
17
|
-
id="sceneInfo"
|
|
18
|
-
style="margin-top: 15px; padding: 10px; background-color: #f5f5f5; border-radius: 4px; max-height: 200px; overflow-y: auto;"
|
|
19
|
-
v-html="sceneInfoHtml"
|
|
20
|
-
></div>
|
|
21
|
-
<div>
|
|
22
|
-
<label>
|
|
23
|
-
<input type="checkbox" v-model="enableTransition" checked>
|
|
24
|
-
启用过渡动画
|
|
25
|
-
</label>
|
|
26
|
-
</div>
|
|
27
|
-
<div class="current-scene">
|
|
28
|
-
当前场景: <span>{{ currentSceneName || '未设置' }}</span>
|
|
29
|
-
</div>
|
|
30
|
-
<div class="info">
|
|
31
|
-
点击按钮切换到不同预设场景,每个场景包含不同的相机位置、目标点和可能的图层可见性设置。
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
</div>
|
|
35
|
-
</template>
|
|
36
|
-
|
|
37
|
-
<script setup>
|
|
38
|
-
import { ref, onMounted, onBeforeUnmount } from 'vue';
|
|
39
|
-
import { Viewer } from '../../index.ts';
|
|
40
|
-
|
|
41
|
-
// 响应式数据
|
|
42
|
-
const viewer = ref(null);
|
|
43
|
-
const modelScenes = ref([]);
|
|
44
|
-
const sceneInfoHtml = ref('场景信息将在这里显示');
|
|
45
|
-
const enableTransition = ref(true);
|
|
46
|
-
const currentSceneName = ref('未设置');
|
|
47
|
-
|
|
48
|
-
// 激活场景
|
|
49
|
-
async function activateScene(scene) {
|
|
50
|
-
if (!viewer.value) return;
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
const success = await viewer.value.scenePageManager.activateSceneByName(
|
|
54
|
-
scene.name,
|
|
55
|
-
enableTransition.value
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
if (success) {
|
|
59
|
-
updateCurrentSceneDisplay();
|
|
60
|
-
displaySceneDetails(scene);
|
|
61
|
-
} else {
|
|
62
|
-
alert(`切换到场景 "${scene.name}" 失败`);
|
|
63
|
-
}
|
|
64
|
-
} catch (error) {
|
|
65
|
-
console.error('切换场景失败:', error);
|
|
66
|
-
alert(`切换到场景 "${scene.name}" 时发生错误`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// 显示场景详细信息
|
|
71
|
-
function displaySceneDetails(scene) {
|
|
72
|
-
let infoHtml = `<strong>场景名称:</strong> ${scene.name}<br>`;
|
|
73
|
-
infoHtml += `<strong>激活状态:</strong> ${scene.active}<br>`;
|
|
74
|
-
infoHtml += `<strong>透视模式:</strong> ${scene.camera?.perspective ? '透视' : '正交'}<br>`;
|
|
75
|
-
|
|
76
|
-
if (scene.camera) {
|
|
77
|
-
infoHtml += `<strong>相机位置:</strong> [${scene.camera.position?.join(', ')}]<br>`;
|
|
78
|
-
infoHtml += `<strong>目标位置:</strong> [${scene.camera.target?.join(', ')}]<br>`;
|
|
79
|
-
if (scene.camera.fov) {
|
|
80
|
-
infoHtml += `<strong>视场角:</strong> ${scene.camera.fov}°<br>`;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (scene.hidden_layers && scene.hidden_layers.length > 0) {
|
|
85
|
-
infoHtml += `<strong>隐藏的图层:</strong> ${scene.hidden_layers.join(', ')}<br>`;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (scene.hidden_layers_index && scene.hidden_layers_index.length > 0) {
|
|
89
|
-
infoHtml += `<strong>隐藏的图层索引:</strong> ${scene.hidden_layers_index.join(', ')}<br>`;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (scene.hidden_entities && scene.hidden_entities.length > 0) {
|
|
93
|
-
infoHtml += `<strong>隐藏的实体数量:</strong> ${scene.hidden_entities.length}<br>`;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
sceneInfoHtml.value = infoHtml;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// 更新当前场景显示
|
|
100
|
-
function updateCurrentSceneDisplay() {
|
|
101
|
-
if (!viewer.value) return;
|
|
102
|
-
currentSceneName.value = viewer.value.scenePageManager.getCurrentSceneName() || '未设置';
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// 辅助函数:获取模型中的场景信息
|
|
106
|
-
function getModelScenes() {
|
|
107
|
-
return viewer.value?.scenePageManager.pages || [];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// 辅助函数:获取特定场景
|
|
111
|
-
function getSceneByName(name) {
|
|
112
|
-
return viewer.value?.scenePageManager.pages.find(page => page.name === name);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// 加载并显示模型中的场景
|
|
116
|
-
function loadAndDisplayModelScenes() {
|
|
117
|
-
if (!viewer.value) return;
|
|
118
|
-
|
|
119
|
-
// 获取模型中的所有场景
|
|
120
|
-
modelScenes.value = viewer.value.scenePageManager.pages || [];
|
|
121
|
-
|
|
122
|
-
if (modelScenes.value.length > 0) {
|
|
123
|
-
// 显示第一个场景的详细信息
|
|
124
|
-
displaySceneDetails(modelScenes.value[0]);
|
|
125
|
-
updateCurrentSceneDisplay();
|
|
126
|
-
} else {
|
|
127
|
-
sceneInfoHtml.value = '未发现场景信息';
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
console.log('已加载并显示模型中的所有场景');
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
onMounted(async () => {
|
|
134
|
-
try {
|
|
135
|
-
// 创建Viewer实例
|
|
136
|
-
const container = document.getElementById('container');
|
|
137
|
-
viewer.value = new Viewer(container, {
|
|
138
|
-
load: {
|
|
139
|
-
cache: {
|
|
140
|
-
enabled: false
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
camera: {
|
|
144
|
-
orbitBehavior: 'free'
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
// 加载测试模型
|
|
149
|
-
await viewer.value.loadZipAsync('../../../assets/dgz/49F酒店室内.dgz');
|
|
150
|
-
console.log('模型加载成功');
|
|
151
|
-
|
|
152
|
-
// 模型加载完成后,检查是否有内置场景
|
|
153
|
-
console.log('模型中的场景:', viewer.value.scenePageManager.pages);
|
|
154
|
-
console.log('场景数量:', viewer.value.scenePageManager.pages.length);
|
|
155
|
-
|
|
156
|
-
// 自动加载模型中的场景
|
|
157
|
-
loadAndDisplayModelScenes();
|
|
158
|
-
|
|
159
|
-
// 暴露viewer和辅助函数到全局以便调试
|
|
160
|
-
window.viewer = viewer.value;
|
|
161
|
-
window.getModelScenes = getModelScenes;
|
|
162
|
-
window.getSceneByName = getSceneByName;
|
|
163
|
-
window.loadAndDisplayModelScenes = loadAndDisplayModelScenes;
|
|
164
|
-
|
|
165
|
-
console.log('场景页面管理器演示已加载');
|
|
166
|
-
console.log('可用场景:', viewer.value.scenePageManager.getAllSceneNames());
|
|
167
|
-
console.log('模型中的场景详情:', viewer.value.scenePageManager.pages);
|
|
168
|
-
} catch (error) {
|
|
169
|
-
console.error('初始化失败:', error);
|
|
170
|
-
alert('模型加载失败,请确保模型文件路径正确');
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
onBeforeUnmount(() => {
|
|
175
|
-
// 清理资源
|
|
176
|
-
if (viewer.value) {
|
|
177
|
-
// 根据Viewer类的API进行适当的清理
|
|
178
|
-
// viewer.value.dispose();
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
</script>
|
|
182
|
-
|
|
183
|
-
<style scoped>
|
|
184
|
-
.scene-page-demo {
|
|
185
|
-
position: relative;
|
|
186
|
-
width: 100vw;
|
|
187
|
-
height: 100vh;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
#container {
|
|
191
|
-
width: 100%;
|
|
192
|
-
height: 100%;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
.control-panel {
|
|
196
|
-
position: absolute;
|
|
197
|
-
top: 20px;
|
|
198
|
-
left: 20px;
|
|
199
|
-
z-index: 100;
|
|
200
|
-
background-color: rgba(255, 255, 255, 0.9);
|
|
201
|
-
padding: 20px;
|
|
202
|
-
border-radius: 8px;
|
|
203
|
-
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
|
204
|
-
max-width: 300px;
|
|
205
|
-
font-family: Arial, sans-serif;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
h2 {
|
|
209
|
-
margin-top: 0;
|
|
210
|
-
color: #333;
|
|
211
|
-
font-size: 18px;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.scene-buttons {
|
|
215
|
-
display: flex;
|
|
216
|
-
flex-direction: column;
|
|
217
|
-
gap: 10px;
|
|
218
|
-
margin-bottom: 20px;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
button {
|
|
222
|
-
padding: 8px 16px;
|
|
223
|
-
background-color: #4CAF50;
|
|
224
|
-
color: white;
|
|
225
|
-
border: none;
|
|
226
|
-
border-radius: 4px;
|
|
227
|
-
cursor: pointer;
|
|
228
|
-
transition: background-color 0.3s;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
button:hover {
|
|
232
|
-
background-color: #45a049;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
.current-scene {
|
|
236
|
-
margin-top: 15px;
|
|
237
|
-
font-weight: bold;
|
|
238
|
-
color: #2c3e50;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.info {
|
|
242
|
-
font-size: 12px;
|
|
243
|
-
color: #666;
|
|
244
|
-
margin-top: 15px;
|
|
245
|
-
}
|
|
246
|
-
</style>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="zh-CN">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
-
<title>场景页面管理器演示 - Vue版本</title>
|
|
8
|
-
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
|
9
|
-
</head>
|
|
10
|
-
|
|
11
|
-
<body>
|
|
12
|
-
<div id="app"></div>
|
|
13
|
-
|
|
14
|
-
<script type="module">
|
|
15
|
-
import ScenePageDemo from './ScenePageDemo.vue';
|
|
16
|
-
|
|
17
|
-
const app = Vue.createApp(ScenePageDemo);
|
|
18
|
-
app.mount('#app');
|
|
19
|
-
</script>
|
|
20
|
-
</body>
|
|
21
|
-
|
|
22
|
-
</html>
|