bc-model-viewer 1.6.16 → 1.6.26
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/hud.html +48 -35
- package/examples/test.dgz +0 -0
- package/package.json +1 -1
package/examples/hud.html
CHANGED
|
@@ -6,27 +6,15 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
7
|
<title>Bc-model-viewer</title>
|
|
8
8
|
<style>
|
|
9
|
-
|
|
9
|
+
body {
|
|
10
10
|
margin: 0;
|
|
11
|
-
padding: 0;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
#container {
|
|
15
11
|
position: relative;
|
|
16
|
-
overflow: hidden;
|
|
17
|
-
width: 100vw;
|
|
18
|
-
height: 100vh;
|
|
19
|
-
background: green;
|
|
20
12
|
}
|
|
21
13
|
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.my-hud .lens-border {
|
|
28
|
-
/* background-image: url('../assets/logo.png'); */
|
|
29
|
-
background-size: cover;
|
|
14
|
+
.demo {
|
|
15
|
+
position: absolute;
|
|
16
|
+
z-index: 1;
|
|
17
|
+
top: 0;
|
|
30
18
|
}
|
|
31
19
|
</style>
|
|
32
20
|
</head>
|
|
@@ -34,36 +22,61 @@
|
|
|
34
22
|
<body>
|
|
35
23
|
<div id="container">
|
|
36
24
|
</div>
|
|
25
|
+
<div class="demo">
|
|
26
|
+
<h2>标签工具演示</h2>
|
|
27
|
+
<button onclick="hudTool.activate()">激活工具</button>
|
|
28
|
+
<button onclick="hudTool.deactivate()">停止</button>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
<button onclick="hudTool.activate({
|
|
32
|
+
fixedY: 1,
|
|
33
|
+
onPut(point, hud) {
|
|
34
|
+
console.log('放置完成', point, hud);
|
|
35
|
+
// hudTool.remove(hud) // 移除指定元素
|
|
36
|
+
}
|
|
37
|
+
})">锁定Y轴为1</button>
|
|
38
|
+
|
|
39
|
+
<button onclick="hudTool.removeLast()">清除上一次标签</button>
|
|
40
|
+
<button onclick="hudTool.clear()">清除所有标签</button>
|
|
41
|
+
<button onclick="hudTool.gets()">获取所有标签</button>
|
|
42
|
+
|
|
43
|
+
</div>
|
|
37
44
|
|
|
38
45
|
<script type="module">
|
|
39
46
|
|
|
40
|
-
import { Viewer,
|
|
41
|
-
|
|
47
|
+
import { Viewer, HUDLabelTool } from '../../index.ts'
|
|
48
|
+
|
|
49
|
+
const container = document.getElementById('container')
|
|
50
|
+
|
|
51
|
+
// 实例化 Viewer 对象
|
|
52
|
+
const viewer = new Viewer(container, {
|
|
53
|
+
style: {
|
|
54
|
+
background: {
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
})
|
|
42
58
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
)
|
|
59
|
+
// 加载测试模型
|
|
60
|
+
await viewer.loadZipAsync('../../assets/hhds.dgz')
|
|
46
61
|
|
|
47
|
-
|
|
62
|
+
// 创建工具 只需要实例化一次
|
|
63
|
+
const hudTool = new HUDLabelTool(viewer)
|
|
48
64
|
|
|
49
|
-
|
|
65
|
+
// 给原点直接添加一个标签
|
|
66
|
+
const hud = hudTool.addByPoint([0, 0, 0], {
|
|
50
67
|
className: 'my-hud',
|
|
51
|
-
html: '<h1
|
|
68
|
+
html: '<h1 style="color: red">原点<h1>'
|
|
52
69
|
})
|
|
53
70
|
|
|
54
|
-
console.log(hud.element);
|
|
55
|
-
|
|
56
|
-
viewer.HUDLabelToolActive({
|
|
57
|
-
fixedY: 1,
|
|
58
|
-
onPut(point, hud) {
|
|
59
|
-
console.log('放置完成', point, hud);
|
|
71
|
+
console.log(hud.element); // 获取don元素
|
|
60
72
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
})
|
|
73
|
+
// 关闭快捷键
|
|
74
|
+
viewer.shortcutManager.toggleShortcuts(false)
|
|
64
75
|
|
|
76
|
+
viewer.activateSceneByName('B1')
|
|
65
77
|
|
|
66
|
-
window.
|
|
78
|
+
window.hudTool = hudTool
|
|
79
|
+
window.viewer = viewer
|
|
67
80
|
</script>
|
|
68
81
|
|
|
69
82
|
</body>
|
|
Binary file
|