s3m-maplibre 0.0.0-stage → 0.2.3
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/LICENSE +202 -0
- package/README.md +265 -2
- package/dist/core/BinaryReader.d.ts +38 -0
- package/dist/core/BinaryReader.d.ts.map +1 -0
- package/dist/core/BinaryReader.js +88 -0
- package/dist/core/BinaryReader.js.map +1 -0
- package/dist/core/DXTTextureDecode.d.ts +21 -0
- package/dist/core/DXTTextureDecode.d.ts.map +1 -0
- package/dist/core/DXTTextureDecode.js +236 -0
- package/dist/core/DXTTextureDecode.js.map +1 -0
- package/dist/core/FeatureInfo.d.ts +31 -0
- package/dist/core/FeatureInfo.d.ts.map +1 -0
- package/dist/core/FeatureInfo.js +94 -0
- package/dist/core/FeatureInfo.js.map +1 -0
- package/dist/core/MeshOpt.d.ts +88 -0
- package/dist/core/MeshOpt.d.ts.map +1 -0
- package/dist/core/MeshOpt.js +325 -0
- package/dist/core/MeshOpt.js.map +1 -0
- package/dist/core/S3MBParser.d.ts +27 -0
- package/dist/core/S3MBParser.d.ts.map +1 -0
- package/dist/core/S3MBParser.js +499 -0
- package/dist/core/S3MBParser.js.map +1 -0
- package/dist/core/types.d.ts +226 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/render/GeometryBuilder.d.ts +49 -0
- package/dist/render/GeometryBuilder.d.ts.map +1 -0
- package/dist/render/GeometryBuilder.js +376 -0
- package/dist/render/GeometryBuilder.js.map +1 -0
- package/dist/render/Picker.d.ts +32 -0
- package/dist/render/Picker.d.ts.map +1 -0
- package/dist/render/Picker.js +164 -0
- package/dist/render/Picker.js.map +1 -0
- package/dist/render/S3MLayer.d.ts +320 -0
- package/dist/render/S3MLayer.d.ts.map +1 -0
- package/dist/render/S3MLayer.js +1014 -0
- package/dist/render/S3MLayer.js.map +1 -0
- package/dist/render/StyleMaterial.d.ts +109 -0
- package/dist/render/StyleMaterial.d.ts.map +1 -0
- package/dist/render/StyleMaterial.js +407 -0
- package/dist/render/StyleMaterial.js.map +1 -0
- package/dist/render/TextureFactory.d.ts +30 -0
- package/dist/render/TextureFactory.d.ts.map +1 -0
- package/dist/render/TextureFactory.js +89 -0
- package/dist/render/TextureFactory.js.map +1 -0
- package/dist/tileset/S3MTileset.d.ts +77 -0
- package/dist/tileset/S3MTileset.d.ts.map +1 -0
- package/dist/tileset/S3MTileset.js +270 -0
- package/dist/tileset/S3MTileset.js.map +1 -0
- package/dist/vendor/meshopt_decoder.module.js +118 -0
- package/docs/API.md +398 -0
- package/package.json +85 -4
- package/src/core/BinaryReader.ts +116 -0
- package/src/core/DXTTextureDecode.ts +260 -0
- package/src/core/FeatureInfo.ts +115 -0
- package/src/core/MeshOpt.ts +389 -0
- package/src/core/S3MBParser.ts +586 -0
- package/src/core/types.ts +213 -0
- package/src/index.ts +72 -0
- package/src/render/GeometryBuilder.ts +475 -0
- package/src/render/Picker.ts +184 -0
- package/src/render/S3MLayer.ts +1277 -0
- package/src/render/StyleMaterial.ts +470 -0
- package/src/render/TextureFactory.ts +107 -0
- package/src/tileset/S3MTileset.ts +314 -0
- package/src/vendor/meshopt_decoder.module.d.ts +31 -0
- package/src/vendor/meshopt_decoder.module.js +118 -0
- package/tools/copy-assets.mjs +28 -0
- package/tools/e2e.mjs +78 -0
- package/tools/lod-probe.mjs +60 -0
- package/tools/meshopt-check.mjs +242 -0
- package/tools/official-oracle.mjs +54 -0
- package/tools/parse-sample.mjs +87 -0
- package/tools/serve.mjs +51 -0
- package/tools/trace-one.mjs +93 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,266 @@
|
|
|
1
|
-
#
|
|
1
|
+
# s3m-maplibre
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**在 MapLibre GL JS 里原生渲染 SuperMap S3M 三维模型** —— 浏览器直接解析 `.s3mb` 瓦片,不需要预先转成 3D Tiles,也不需要 SuperMap 的 WebGL 客户端。
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
[](./src/index.ts)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 为什么需要它
|
|
12
|
+
|
|
13
|
+
SuperMap 的 S3M(Spatial 3D Model)是国内 GIS 项目里非常常见的三维格式,iServer 的 `realspace` 服务默认就发布成 S3M。但它和 MapLibre / Mapbox 生态是断开的:
|
|
14
|
+
|
|
15
|
+
- 官方只有 Cesium 系的 WebGL 客户端;
|
|
16
|
+
- 转 3D Tiles 是离线批处理,数据一更新就得重跑,做不到实时;
|
|
17
|
+
- 转出来的 3D Tiles 还要再丢一次精度。
|
|
18
|
+
|
|
19
|
+
这个库走的是**第二条路**:在浏览器里直接解析 S3MB 二进制,用 three.js 画在 MapLibre 的自定义图层上。数据更新即时可见,不需要任何预处理。
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
iServer / 本地目录 → .scp 配置 + .s3mb 瓦片
|
|
23
|
+
↓ fetch + 解压 + 二进制解析
|
|
24
|
+
three.js 几何 + 材质
|
|
25
|
+
↓ ENU → Web Mercator
|
|
26
|
+
MapLibre custom layer (3d)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 能力
|
|
32
|
+
|
|
33
|
+
| 能力 | 状态 | 说明 |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| S3MB 解析 | ✅ | v1.0 / v2.0 / v3.0,9 个官方样例字节级对齐 |
|
|
36
|
+
| MeshOpt 几何压缩 | ✅ | v3 默认压缩方式,浏览器内 wasm 解码,按需加载 |
|
|
37
|
+
| LOD 渐进加载 | ✅ | 支持 `Distance_From_EyePoint` / `Pixel_Size_OnScreen` |
|
|
38
|
+
| 多数据集叠加 | ✅ | 各数据集独立锚点,自动对齐到统一场景原点 |
|
|
39
|
+
| 白膜 / 单色 | ✅ | |
|
|
40
|
+
| 按高度 / 按楼层着色 | ✅ | 高度范围自动统计 |
|
|
41
|
+
| 按单体着色 | ✅ | 基于 S3M 单体化信息 |
|
|
42
|
+
| 动态扫描 | ✅ | 扫描线沿高度循环 |
|
|
43
|
+
| 透明度 | ✅ | 实时,不重编译着色器 |
|
|
44
|
+
| 选中高亮 + 描边 | ✅ | 单体级 |
|
|
45
|
+
| 全局棱线 | ✅ | 优先用数据自带棱线包,没有才 CPU 现算 |
|
|
46
|
+
| 单体级点选 + 属性 | ✅ | GPU 拾取,代价与面数无关 |
|
|
47
|
+
| 实例化几何 | ✅ | `instanceMode` 16 / 17 |
|
|
48
|
+
| DXT / WebP 纹理 | ✅ | |
|
|
49
|
+
| Draco 压缩几何 | ❌ | 遇到会抛明确错误 |
|
|
50
|
+
| KTX2 / CRN | ❌ | |
|
|
51
|
+
| 骨骼动画 | ❌ | 已解析未驱动 |
|
|
52
|
+
| 地形遮挡 | ❌ | |
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 安装
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install s3m-maplibre three
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`three` 是 peer 依赖(`>=0.168.0`)。`maplibre-gl` 不是依赖——图层只是一个符合 `CustomLayerInterface` 的普通对象,MapLibre / Mapbox 都能挂。
|
|
63
|
+
|
|
64
|
+
类型随包发布(`dist/index.d.ts`,由源码直接生成)。three `>=0.168` 自带类型,更老的版本需要自己装 `@types/three`。
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 快速开始
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
import maplibregl from 'maplibre-gl';
|
|
72
|
+
import { S3MLayer, STYLE } from 's3m-maplibre';
|
|
73
|
+
|
|
74
|
+
const map = new maplibregl.Map({
|
|
75
|
+
container: 'map',
|
|
76
|
+
style: 'https://demotiles.maplibre.org/style.json',
|
|
77
|
+
center: [121.4739, 31.244],
|
|
78
|
+
zoom: 16.5,
|
|
79
|
+
pitch: 60,
|
|
80
|
+
antialias: true, // 建筑边缘需要抗锯齿
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const layer = new S3MLayer({
|
|
84
|
+
datasets: [
|
|
85
|
+
{
|
|
86
|
+
id: 'jingmo',
|
|
87
|
+
name: '精模',
|
|
88
|
+
configUrl: 'https://host/iserver/services/svc/rest/realspace/datas/jingmo/data/path/jingmo.scp',
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
style: { mode: STYLE.WHITE, opacity: 0.92 },
|
|
92
|
+
onPick: (f) => console.log(f?.smid, f?.height, f?.floors),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
map.on('load', () => map.addLayer(layer));
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 叠加多个数据集 + 换着色
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
const layer = new S3MLayer({
|
|
102
|
+
datasets: [
|
|
103
|
+
{ id: 'zhoubian', name: '周边底模', configUrl: '.../zhoubian.scp' },
|
|
104
|
+
{ id: 'jingmo', name: '精模', configUrl: '.../jingmo.scp' },
|
|
105
|
+
],
|
|
106
|
+
maxTiles: 48,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
await layer.addDataset({ id: 'cheng', name: 'cheng', configUrl: '.../cheng.scp' });
|
|
110
|
+
|
|
111
|
+
layer.setStyle({ mode: STYLE.HEIGHT, colorA: '#e2e8f0', colorB: '#1d4ed8' });
|
|
112
|
+
layer.setDatasetVisible('zhoubian', false);
|
|
113
|
+
layer.setEdges(true);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 点选
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
map.on('click', (e) => {
|
|
120
|
+
const f = layer.pickFromEvent(e);
|
|
121
|
+
if (!f) return layer.select(null);
|
|
122
|
+
layer.select(f);
|
|
123
|
+
console.log(`${f.datasetName} · SMID ${f.smid} · ${f.height}m · ${f.floors}层`);
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
完整接口见 **[docs/API.md](./docs/API.md)**。
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 演示
|
|
132
|
+
|
|
133
|
+
仓库内 `demo/` 是一个完整示例,接了上海某区的真实 iServer 服务(5 个数据集叠加,45 万三角面):
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npm run demo # http://localhost:8123/s3m-maplibre/demo/index.html
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
演示包含:数据集叠加开关、7 种着色模式、透明度、平面/平滑着色、选中描边、全局棱线、点击属性卡。
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## 工作原理
|
|
144
|
+
|
|
145
|
+
### 解析
|
|
146
|
+
|
|
147
|
+
S3MB 是「文件头 + 压缩段」结构:`float version` → (v3) `uint32 compressedType` → (v2+) `uint32 uncompressedSize` → `uint32 compressedSize` → 压缩载荷。解压后是严格的顺序流:
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
fileOptions
|
|
151
|
+
GroupNode → PageLOD[] → Geode[](matrix4d + skeletonNames)
|
|
152
|
+
Skeleton[] → VertexDataPackage + IndexPackage[]
|
|
153
|
+
Textures / Materials
|
|
154
|
+
PickInfo(单体化:SMID → batchId + 顶点区间)
|
|
155
|
+
Extensions(v3)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
解析器是纯 TS,**不依赖 three 和 WebGL**,可以在 Node 里跑,用 `bytesRead === bytesTotal` 自检偏移是否正确。
|
|
159
|
+
|
|
160
|
+
### MeshOpt 压缩几何
|
|
161
|
+
|
|
162
|
+
iServer 现在默认用 MeshOpt 压几何(`VertexTag = 2`),瓦片里的顶点流是 meshoptimizer 编码过的量化数据。处理方式:
|
|
163
|
+
|
|
164
|
+
- **解码器**直接内联 [meshoptimizer](https://github.com/zeux/meshoptimizer) 0.17 的 wasm 解码器(MIT,约 22KB),只有真的遇到 MeshOpt 瓦片才动态 `import`;
|
|
165
|
+
- **容器结构**按真实数据逐字节标定(规范里的 `CompressedDataPackage` 已经落后于 v3.01 的实际数据),量化公式用瓦片自带的 OBB 反推验证:
|
|
166
|
+
```
|
|
167
|
+
position = minVerticesValue + uint16 * vertCompressConstant
|
|
168
|
+
texcoord = minTexCoordValue[i] + uint16 * texCoordCompressConstant[i]
|
|
169
|
+
normal = octDecode(int16 / 32767)
|
|
170
|
+
```
|
|
171
|
+
- 官方 `ParseMeshOpt.js` **不能直接搬运**:它被混淆过,而且在描述字符串之后多推进 4 字节,遇到现在 iServer 发的 v3.01 数据必然崩在索引包上。
|
|
172
|
+
|
|
173
|
+
### 索引包类型
|
|
174
|
+
|
|
175
|
+
一个骨架可以带多个索引包,`primitiveType` 决定怎么画:
|
|
176
|
+
|
|
177
|
+
| primitiveType | 含义 | 画法 |
|
|
178
|
+
|---|---|---|
|
|
179
|
+
| 4 | 独立三角形 | `Mesh` |
|
|
180
|
+
| 13 | **数据自带的棱线包**(规范里没写,实测就是建筑轮廓线) | `LineSegments` |
|
|
181
|
+
| 其他 | 点 / 线 / 条带 | 跳过 |
|
|
182
|
+
|
|
183
|
+
把 13 当三角形画,每条棱线都会被连成一根几十上百米的尖刺 —— 这是踩过的坑,写在这里省下一个人一天。
|
|
184
|
+
|
|
185
|
+
### 坐标
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
S3M 顶点(数据集局部 ENU,米)
|
|
189
|
+
→ 数据集 Group 偏移(各锚点对齐到场景锚点)
|
|
190
|
+
→ L 矩阵:ENU → Web Mercator 归一化
|
|
191
|
+
→ MapLibre 传入的 mercator→clip
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
场景原点固定在第一个数据集的锚点,顶点只保留「相对锚点的米」——等价于 3D Tiles 的 `RTC_CENTER`,避免 float32 在大坐标下抖动。
|
|
195
|
+
|
|
196
|
+
### 着色
|
|
197
|
+
|
|
198
|
+
所有模式都在同一个 `MeshStandardMaterial` 的片元着色器里用 `uMode` 分支实现,uniform 全局共享。切换样式不重建几何、不重建材质、不重编译着色器。
|
|
199
|
+
|
|
200
|
+
### 拾取
|
|
201
|
+
|
|
202
|
+
「物体编号 + batchId」编码成 RGBA 渲到离屏目标,点击时读那一个像素。代价与三角面数无关,深度测试由 GPU 完成,天然只命中最前面的可见面。
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## 验证情况
|
|
207
|
+
|
|
208
|
+
- **解析正确性**:9 个官方样例(v1 / v2 / v3)全部 `bytesRead === bytesTotal`;并用官方 `S3ModelParser.js` 在 Node 里做逐段偏移对照。
|
|
209
|
+
- **MeshOpt 解码**:`npm run test:meshopt` 跑 60 个真实瓦片(5 个数据集 × 根瓦片 + 一级子瓦片),逐项校验偏移对齐、索引不越界、三角形索引数是 3 的倍数、法线归一化、顶点包围盒与 OBB 尺寸一致 —— 60/60 通过。
|
|
210
|
+
- **真实服务**:上海某区 iServer `realspace` 服务,S3M 3.01、`epsg:4326`、DXT 纹理压缩、5 个数据集叠加,20 个瓦片 / 45 万三角面稳定 85~90 fps。
|
|
211
|
+
- **拾取正确性**:以射线求交为真值,对 135 个像素采样,有效像素 96/96 一致(其余 39 个是两个数据集几何完全重合的平局)。
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## 性能
|
|
216
|
+
|
|
217
|
+
| 项 | 数值 |
|
|
218
|
+
|---|---|
|
|
219
|
+
| 45 万三角面 / 20 瓦片 / 1440×900 | 85~90 fps |
|
|
220
|
+
| 拾取单次 | < 1 ms(与面数无关) |
|
|
221
|
+
| 棱线构建 | 8ms 一帧切片,20 网格约 1.9s 总计,不阻塞交互 |
|
|
222
|
+
|
|
223
|
+
调优建议见 [docs/API.md#性能调优](./docs/API.md#性能调优)。
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## 已知限制
|
|
228
|
+
|
|
229
|
+
- **Draco 压缩几何**未实现。MeshOpt 已支持;遇到 Draco 会抛带说明的错误。
|
|
230
|
+
- **地形遮挡**未实现:MapLibre 的地形深度没进 custom layer 的深度缓冲,建筑不会被地形裁掉。
|
|
231
|
+
- 每个 `indexPackage` 一个 `Mesh`,倾斜摄影大瓦片需要合批。
|
|
232
|
+
- `texmodmatrix`(纹理变换)未应用。
|
|
233
|
+
- 跨城市量级的数据集叠加会重新引入 float32 精度问题。
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 目录结构
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
src/
|
|
241
|
+
core/ 解析层(无 three 依赖,Node 可用)
|
|
242
|
+
BinaryReader.ts 小端二进制读取
|
|
243
|
+
S3MBParser.ts S3MB 结构解析
|
|
244
|
+
MeshOpt.ts MeshOpt 几何压缩解码(量化还原 + 八面体法线)
|
|
245
|
+
FeatureInfo.ts 单体属性反推
|
|
246
|
+
DXTTextureDecode.ts DXT 解码(来自 SuperMap/s3m-spec)
|
|
247
|
+
tileset/ 瓦片树 + LOD + 加载调度
|
|
248
|
+
render/ three 渲染
|
|
249
|
+
S3MLayer.ts 图层主体(多数据集 / 样式 / 拾取)
|
|
250
|
+
GeometryBuilder.ts 几何与材质组装
|
|
251
|
+
StyleMaterial.ts 着色器注入的着色系统
|
|
252
|
+
Picker.ts GPU 拾取
|
|
253
|
+
TextureFactory.ts 纹理解码
|
|
254
|
+
vendor/ meshoptimizer 解码器(wasm 内联,原样保留)
|
|
255
|
+
demo/ 演示
|
|
256
|
+
tools/ 自检脚本(解析校验、MeshOpt 回归、静态服务)
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 许可
|
|
262
|
+
|
|
263
|
+
- 本项目 [Apache-2.0](./LICENSE)。
|
|
264
|
+
- `src/core/DXTTextureDecode.ts` 来自 [SuperMap/s3m-spec](https://github.com/supermap/s3m-spec)(Apache-2.0)。
|
|
265
|
+
- `src/vendor/meshopt_decoder.module.js` 是 [meshoptimizer](https://github.com/zeux/meshoptimizer) 官方解码器(MIT,© Arseny Kapoulkine),未做修改。
|
|
266
|
+
- S3M 规范文本遵循 CC BY-ND 4.0,不得修改规范文本后再发布。
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S3M 二进制读取器
|
|
3
|
+
*
|
|
4
|
+
* 约定全部来自 SuperMap/s3m-spec 的 S3ModelParser.js(Apache-2.0):
|
|
5
|
+
* - 小端字节序
|
|
6
|
+
* - String = uint32 字节长度 + UTF-8 字节(无结尾 0)
|
|
7
|
+
* - 多处需要按 4 字节对齐,且对齐基准点不同(绝对偏移 / 流起点)
|
|
8
|
+
*/
|
|
9
|
+
import type { BoundingBox, Vec3 } from './types.js';
|
|
10
|
+
export declare class BinaryReader {
|
|
11
|
+
readonly buffer: ArrayBuffer;
|
|
12
|
+
readonly base: number;
|
|
13
|
+
readonly view: DataView;
|
|
14
|
+
offset: number;
|
|
15
|
+
private readonly _decoder;
|
|
16
|
+
constructor(buffer: ArrayBuffer, byteOffset?: number, byteLength?: number);
|
|
17
|
+
get remaining(): number;
|
|
18
|
+
u8(): number;
|
|
19
|
+
u16(): number;
|
|
20
|
+
u32(): number;
|
|
21
|
+
i32(): number;
|
|
22
|
+
f32(): number;
|
|
23
|
+
f64(): number;
|
|
24
|
+
/** 返回原始字节视图(不拷贝,生命周期绑定底层 buffer) */
|
|
25
|
+
bytes(n: number): Uint8Array;
|
|
26
|
+
/** 返回拷贝,用于纹理等需要脱离源 buffer 的数据 */
|
|
27
|
+
bytesCopy(n: number): Uint8Array;
|
|
28
|
+
string(): string;
|
|
29
|
+
skip(n: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* 4 字节对齐。rel 是对齐基准在流中的偏移,默认 0(即整个流起点)。
|
|
32
|
+
* 纹理流用的是「纹理流起点」而不是文件起点,所以要显式传。
|
|
33
|
+
*/
|
|
34
|
+
align4(rel?: number): void;
|
|
35
|
+
vec3f64(): Vec3;
|
|
36
|
+
boundingBox(): BoundingBox;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=BinaryReader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BinaryReader.d.ts","sourceRoot":"","sources":["../../src/core/BinaryReader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEpD,qBAAa,YAAY;IACvB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;gBAEzC,MAAM,EAAE,WAAW,EAAE,UAAU,SAAI,EAAE,UAAU,CAAC,EAAE,MAAM;IAWpE,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,EAAE,IAAI,MAAM;IAMZ,GAAG,IAAI,MAAM;IAMb,GAAG,IAAI,MAAM;IAMb,GAAG,IAAI,MAAM;IAMb,GAAG,IAAI,MAAM;IAMb,GAAG,IAAI,MAAM;IAMb,oCAAoC;IACpC,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU;IAM5B,iCAAiC;IACjC,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU;IAMhC,MAAM,IAAI,MAAM;IAOhB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAIrB;;;OAGG;IACH,MAAM,CAAC,GAAG,SAAI,GAAG,IAAI;IAKrB,OAAO,IAAI,IAAI;IAIf,WAAW,IAAI,WAAW;CAQ3B"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export class BinaryReader {
|
|
2
|
+
buffer;
|
|
3
|
+
base;
|
|
4
|
+
view;
|
|
5
|
+
offset;
|
|
6
|
+
_decoder = new TextDecoder('utf-8');
|
|
7
|
+
constructor(buffer, byteOffset = 0, byteLength) {
|
|
8
|
+
this.buffer = buffer;
|
|
9
|
+
this.base = byteOffset;
|
|
10
|
+
this.view = new DataView(buffer, byteOffset, byteLength === undefined ? buffer.byteLength - byteOffset : byteLength);
|
|
11
|
+
this.offset = 0;
|
|
12
|
+
}
|
|
13
|
+
get remaining() {
|
|
14
|
+
return this.view.byteLength - this.offset;
|
|
15
|
+
}
|
|
16
|
+
u8() {
|
|
17
|
+
const v = this.view.getUint8(this.offset);
|
|
18
|
+
this.offset += 1;
|
|
19
|
+
return v;
|
|
20
|
+
}
|
|
21
|
+
u16() {
|
|
22
|
+
const v = this.view.getUint16(this.offset, true);
|
|
23
|
+
this.offset += 2;
|
|
24
|
+
return v;
|
|
25
|
+
}
|
|
26
|
+
u32() {
|
|
27
|
+
const v = this.view.getUint32(this.offset, true);
|
|
28
|
+
this.offset += 4;
|
|
29
|
+
return v;
|
|
30
|
+
}
|
|
31
|
+
i32() {
|
|
32
|
+
const v = this.view.getInt32(this.offset, true);
|
|
33
|
+
this.offset += 4;
|
|
34
|
+
return v;
|
|
35
|
+
}
|
|
36
|
+
f32() {
|
|
37
|
+
const v = this.view.getFloat32(this.offset, true);
|
|
38
|
+
this.offset += 4;
|
|
39
|
+
return v;
|
|
40
|
+
}
|
|
41
|
+
f64() {
|
|
42
|
+
const v = this.view.getFloat64(this.offset, true);
|
|
43
|
+
this.offset += 8;
|
|
44
|
+
return v;
|
|
45
|
+
}
|
|
46
|
+
/** 返回原始字节视图(不拷贝,生命周期绑定底层 buffer) */
|
|
47
|
+
bytes(n) {
|
|
48
|
+
const a = new Uint8Array(this.buffer, this.base + this.offset, n);
|
|
49
|
+
this.offset += n;
|
|
50
|
+
return a;
|
|
51
|
+
}
|
|
52
|
+
/** 返回拷贝,用于纹理等需要脱离源 buffer 的数据 */
|
|
53
|
+
bytesCopy(n) {
|
|
54
|
+
const a = new Uint8Array(this.buffer, this.base + this.offset, n);
|
|
55
|
+
this.offset += n;
|
|
56
|
+
return a.slice();
|
|
57
|
+
}
|
|
58
|
+
string() {
|
|
59
|
+
const len = this.u32();
|
|
60
|
+
const a = new Uint8Array(this.buffer, this.base + this.offset, len);
|
|
61
|
+
this.offset += len;
|
|
62
|
+
return this._decoder.decode(a);
|
|
63
|
+
}
|
|
64
|
+
skip(n) {
|
|
65
|
+
this.offset += n;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 4 字节对齐。rel 是对齐基准在流中的偏移,默认 0(即整个流起点)。
|
|
69
|
+
* 纹理流用的是「纹理流起点」而不是文件起点,所以要显式传。
|
|
70
|
+
*/
|
|
71
|
+
align4(rel = 0) {
|
|
72
|
+
const m = (this.offset - rel) % 4;
|
|
73
|
+
if (m !== 0)
|
|
74
|
+
this.skip(4 - m);
|
|
75
|
+
}
|
|
76
|
+
vec3f64() {
|
|
77
|
+
return { x: this.f64(), y: this.f64(), z: this.f64() };
|
|
78
|
+
}
|
|
79
|
+
boundingBox() {
|
|
80
|
+
return {
|
|
81
|
+
center: this.vec3f64(),
|
|
82
|
+
xExtent: this.vec3f64(),
|
|
83
|
+
yExtent: this.vec3f64(),
|
|
84
|
+
zExtent: this.vec3f64(),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=BinaryReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BinaryReader.js","sourceRoot":"","sources":["../../src/core/BinaryReader.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DXT1 / DXT3 / DXT5 纹理解码(squish 算法的 JS 移植)
|
|
3
|
+
*
|
|
4
|
+
* 来源:SuperMap iClient3D S3M SDK(Apache-2.0)。
|
|
5
|
+
* 迁移到 TS 时做了两件事,算法本身未改:
|
|
6
|
+
* 1. 补齐类型;
|
|
7
|
+
* 2. 修掉 `DecompressAlphaDxt3` 里把 `block` 误写成未定义全局 `bytes` 的笔误
|
|
8
|
+
* (DXT3 纹理此前会直接 ReferenceError)。
|
|
9
|
+
*/
|
|
10
|
+
declare const DXTTextureDecode: {
|
|
11
|
+
/**
|
|
12
|
+
* @param out 输出缓冲,长度须为 width*height*4
|
|
13
|
+
* @param width 像素宽
|
|
14
|
+
* @param height 像素高
|
|
15
|
+
* @param block 压缩块
|
|
16
|
+
* @param format S3M pixelFormat(>11 或 5 走 DXT5,其余走 DXT1)
|
|
17
|
+
*/
|
|
18
|
+
decode(out: Uint8Array, width: number, height: number, block: Uint8Array, format: number): void;
|
|
19
|
+
};
|
|
20
|
+
export default DXTTextureDecode;
|
|
21
|
+
//# sourceMappingURL=DXTTextureDecode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DXTTextureDecode.d.ts","sourceRoot":"","sources":["../../src/core/DXTTextureDecode.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAoOH,QAAA,MAAM,gBAAgB;IACpB;;;;;;OAMG;gBACS,UAAU,SAAS,MAAM,UAAU,MAAM,SAAS,UAAU,UAAU,MAAM,GAAG,IAAI;CAahG,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|