-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
58 lines (47 loc) · 1.48 KB
/
main.js
File metadata and controls
58 lines (47 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import workJSON from '@realsee/open-works/virtual/81RojBlJQdVTglNNMr/work.json';
import { Five } from '@realsee/five';
import './style.css';
const $app = document.querySelector('#app');
// five初始化参数请参考
// https://unpkg.com/@realsee/five@latest/docs/interfaces/five.FiveInitArgs.html
const five = new Five({
imageOptions: {
// 初始512开启动态瓦片加载,可提升点位加载速度
size: 512,
},
textureOptions: {
// 关闭模型贴图自动缩放,加载高精度模型贴图,
// 注意,低性能的机器大模型场景容易崩溃
autoResize: false,
},
});
five.load(workJSON);
five.appendTo($app);
// 当容器div尺寸变化时进行画布刷新
window.addEventListener('resize', () => five.refresh());
// 添加切换按钮
const $button = document.createElement('button');
$button.innerText = '切换成模型态';
$button.addEventListener('click', (ev) => {
console.log(ev);
// 当前为全景模式
if (five.getCurrentState().mode === Five.Mode.Panorama) {
five.changeMode(Five.Mode.Floorplan);
return;
}
// 当前为模型态
if (five.getCurrentState().mode === Five.Mode.Floorplan) {
five.changeMode(Five.Mode.Panorama);
return;
}
});
five.on('modeChange', (mode) => {
if (mode === Five.Mode.Panorama) {
$button.innerText = '切换成模型态';
}
if (mode === Five.Mode.Floorplan) {
$button.innerText = '切换成全景态';
}
});
$button.classList.add('btn');
$app.appendChild($button);