s3m-three 0.0.0-stage → 0.1.0
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 +57 -2
- package/dist/core/AttributeQuery.d.ts +97 -0
- package/dist/core/AttributeQuery.d.ts.map +1 -0
- package/dist/core/AttributeQuery.js +221 -0
- package/dist/core/AttributeQuery.js.map +1 -0
- 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/CRNDecode.d.ts +13 -0
- package/dist/core/CRNDecode.d.ts.map +1 -0
- package/dist/core/CRNDecode.js +84 -0
- package/dist/core/CRNDecode.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 +45 -0
- package/dist/core/FeatureInfo.d.ts.map +1 -0
- package/dist/core/FeatureInfo.js +125 -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 +336 -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 +503 -0
- package/dist/core/S3MBParser.js.map +1 -0
- package/dist/core/TextureFormat.d.ts +44 -0
- package/dist/core/TextureFormat.d.ts.map +1 -0
- package/dist/core/TextureFormat.js +97 -0
- package/dist/core/TextureFormat.js.map +1 -0
- package/dist/core/types.d.ts +235 -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 +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/render/CoordinateHelper.d.ts +90 -0
- package/dist/render/CoordinateHelper.d.ts.map +1 -0
- package/dist/render/CoordinateHelper.js +85 -0
- package/dist/render/CoordinateHelper.js.map +1 -0
- package/dist/render/DatasetManager.d.ts +109 -0
- package/dist/render/DatasetManager.d.ts.map +1 -0
- package/dist/render/DatasetManager.js +229 -0
- package/dist/render/DatasetManager.js.map +1 -0
- package/dist/render/EdgeLines.d.ts +69 -0
- package/dist/render/EdgeLines.d.ts.map +1 -0
- package/dist/render/EdgeLines.js +293 -0
- package/dist/render/EdgeLines.js.map +1 -0
- package/dist/render/FeatureStyleManager.d.ts +159 -0
- package/dist/render/FeatureStyleManager.d.ts.map +1 -0
- package/dist/render/FeatureStyleManager.js +629 -0
- package/dist/render/FeatureStyleManager.js.map +1 -0
- package/dist/render/GeoAdapter.d.ts +56 -0
- package/dist/render/GeoAdapter.d.ts.map +1 -0
- package/dist/render/GeoAdapter.js +49 -0
- package/dist/render/GeoAdapter.js.map +1 -0
- package/dist/render/GeometryBuilder.d.ts +56 -0
- package/dist/render/GeometryBuilder.d.ts.map +1 -0
- package/dist/render/GeometryBuilder.js +694 -0
- package/dist/render/GeometryBuilder.js.map +1 -0
- package/dist/render/GroundManager.d.ts +61 -0
- package/dist/render/GroundManager.d.ts.map +1 -0
- package/dist/render/GroundManager.js +221 -0
- package/dist/render/GroundManager.js.map +1 -0
- package/dist/render/OrthoProjection.d.ts +84 -0
- package/dist/render/OrthoProjection.d.ts.map +1 -0
- package/dist/render/OrthoProjection.js +141 -0
- package/dist/render/OrthoProjection.js.map +1 -0
- package/dist/render/Picker.d.ts +43 -0
- package/dist/render/Picker.d.ts.map +1 -0
- package/dist/render/Picker.js +266 -0
- package/dist/render/Picker.js.map +1 -0
- package/dist/render/S3MLayer.d.ts +457 -0
- package/dist/render/S3MLayer.d.ts.map +1 -0
- package/dist/render/S3MLayer.js +1860 -0
- package/dist/render/S3MLayer.js.map +1 -0
- package/dist/render/S3MViewer.d.ts +390 -0
- package/dist/render/S3MViewer.d.ts.map +1 -0
- package/dist/render/S3MViewer.js +1713 -0
- package/dist/render/S3MViewer.js.map +1 -0
- package/dist/render/StyleMaterial.d.ts +164 -0
- package/dist/render/StyleMaterial.d.ts.map +1 -0
- package/dist/render/StyleMaterial.js +481 -0
- package/dist/render/StyleMaterial.js.map +1 -0
- package/dist/render/TextureFactory.d.ts +33 -0
- package/dist/render/TextureFactory.d.ts.map +1 -0
- package/dist/render/TextureFactory.js +117 -0
- package/dist/render/TextureFactory.js.map +1 -0
- package/dist/tileset/S3MTileset.d.ts +129 -0
- package/dist/tileset/S3MTileset.d.ts.map +1 -0
- package/dist/tileset/S3MTileset.js +479 -0
- package/dist/tileset/S3MTileset.js.map +1 -0
- package/dist/vendor/crunch_decoder.module.js +1140 -0
- package/dist/vendor/meshopt_decoder.module.js +118 -0
- package/docs/API.md +744 -0
- package/package.json +67 -4
- package/src/core/AttributeQuery.ts +268 -0
- package/src/core/BinaryReader.ts +116 -0
- package/src/core/CRNDecode.ts +107 -0
- package/src/core/DXTTextureDecode.ts +260 -0
- package/src/core/FeatureInfo.ts +150 -0
- package/src/core/MeshOpt.ts +401 -0
- package/src/core/S3MBParser.ts +590 -0
- package/src/core/TextureFormat.ts +103 -0
- package/src/core/types.ts +222 -0
- package/src/index.ts +134 -0
- package/src/render/DatasetManager.ts +301 -0
- package/src/render/EdgeLines.ts +343 -0
- package/src/render/FeatureStyleManager.ts +773 -0
- package/src/render/GeoAdapter.ts +72 -0
- package/src/render/GeometryBuilder.ts +840 -0
- package/src/render/GroundManager.ts +245 -0
- package/src/render/OrthoProjection.ts +189 -0
- package/src/render/Picker.ts +293 -0
- package/src/render/S3MViewer.ts +1980 -0
- package/src/render/StyleMaterial.ts +602 -0
- package/src/render/TextureFactory.ts +134 -0
- package/src/tileset/S3MTileset.ts +552 -0
- package/src/vendor/crunch_decoder.module.d.ts +27 -0
- package/src/vendor/crunch_decoder.module.js +1140 -0
- package/src/vendor/meshopt_decoder.module.d.ts +31 -0
- package/src/vendor/meshopt_decoder.module.js +118 -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,58 @@
|
|
|
1
|
-
#
|
|
1
|
+
# s3m-three
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SuperMap S3M 三维模型格式的 **three.js 渲染内核**(宿主无关)。
|
|
4
|
+
|
|
5
|
+
浏览器内直接解析 `.s3mb` 瓦片,不需要预先转成 3D Tiles,也不需要 SuperMap 的 WebGL 客户端:
|
|
6
|
+
|
|
7
|
+
- `core/` 纯解析(无 three 依赖,Node 可跑)
|
|
8
|
+
- `tileset/` 瓦片树 + LOD + 加载调度
|
|
9
|
+
- `render/S3MViewer` 宿主无关场景查看器:多数据集叠加、白膜 / 按高度 / 按单体 / 动态扫描着色、单体级 GPU 拾取、选中描边、单体样式与业务字段专题着色
|
|
10
|
+
|
|
11
|
+
## 安装
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install s3m-three three
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`three` 是 peer 依赖(`>=0.168.0`)。
|
|
18
|
+
|
|
19
|
+
## 30 秒上手
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import * as THREE from 'three';
|
|
23
|
+
import { S3MViewer } from 's3m-three';
|
|
24
|
+
|
|
25
|
+
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
|
26
|
+
document.body.appendChild(renderer.domElement);
|
|
27
|
+
|
|
28
|
+
const viewer = new S3MViewer({ configUrl: 'https://host/.../config' });
|
|
29
|
+
viewer.mount(renderer.domElement, renderer.getContext());
|
|
30
|
+
|
|
31
|
+
const camera = new THREE.PerspectiveCamera(55, innerWidth / innerHeight, 1, 60000);
|
|
32
|
+
const mvp = new THREE.Matrix4();
|
|
33
|
+
|
|
34
|
+
function tick() {
|
|
35
|
+
// 你自己的相机与投影矩阵;viewer 只负责把 S3M 瓦片画进去
|
|
36
|
+
camera.updateProjectionMatrix();
|
|
37
|
+
camera.updateMatrixWorld(true);
|
|
38
|
+
mvp.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
39
|
+
viewer.renderFrame({
|
|
40
|
+
mvp: mvp.elements,
|
|
41
|
+
cameraEnu: [camera.position.x, -camera.position.z, camera.position.y], // three(y↑) → ENU(z↑)
|
|
42
|
+
fovRad: THREE.MathUtils.degToRad(camera.fov),
|
|
43
|
+
canvasHeight: renderer.domElement.height,
|
|
44
|
+
});
|
|
45
|
+
requestAnimationFrame(tick);
|
|
46
|
+
}
|
|
47
|
+
tick();
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
地理坐标通过可注入的 `GeoAdapter` 接口适配(默认标准 Web 墨卡托兜底);
|
|
51
|
+
接 MapLibre / Mapbox 请改用 [`s3m-maplibre`](https://www.npmjs.com/package/s3m-maplibre) 的 `S3MLayer`。
|
|
52
|
+
|
|
53
|
+
完整 API 见 **[docs/API.md](./docs/API.md)**(样式系统、字段着色、底层解析、性能调优);
|
|
54
|
+
架构说明与在线演示见 <https://github.com/joo1es/s3m-maplibre>。
|
|
55
|
+
|
|
56
|
+
## 许可
|
|
57
|
+
|
|
58
|
+
Apache-2.0
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* iServer 数据服务属性查询
|
|
3
|
+
*
|
|
4
|
+
* S3M 瓦片里**只有单体 ID**(`MonomerIDInfo.id`,即 SmID)和顶点区间,没有任何业务字段;
|
|
5
|
+
* 业务属性在 iServer 的「数据服务」里:同一份数据源被发布成 `data-xxx/rest/data` 的那个服务。
|
|
6
|
+
*
|
|
7
|
+
* 这里的职责只有一件事:按 SmID 批量取字段值。字段表、分片、缓存、去重都在内部消化,
|
|
8
|
+
* 上层(`S3MLayer.colorByField`)只关心「拿到值之后怎么算颜色」。
|
|
9
|
+
*
|
|
10
|
+
* 实测(iServer 2026,GEOMODEL3D 数据集):
|
|
11
|
+
* - `queryOption: 'ATTRIBUTE'` 被忽略:放 body、放 query string、大小写都没用,
|
|
12
|
+
* 2D / 3D 数据集都照样返回几何;模型数据集还会给每条要素带上 `geometry.model`
|
|
13
|
+
* —— 那是 deflate 压缩后的 S3M 模型字节,约 2.5KB/条,占整个响应的 90%;
|
|
14
|
+
* - 没有「只取属性」的接口。想省带宽只能逐条 GET `/rest/data/feature/{a}-{b}-{idx}.json`
|
|
15
|
+
* (957B/条,model 为 null),但那是拿请求数换带宽:300 条并发 16 反而比一次 POST 慢;
|
|
16
|
+
* - `.fastjson` 比 `.json` 少 40%:model 用 hex(2 字符/字节)而不是数字数组(3~4 字符/字节)。
|
|
17
|
+
* 代价是它不是严格 JSON(`0.0D`、`1L`、`x'ABCD'` 都是 Java 字面量),要先清洗;
|
|
18
|
+
* - `maxFeatures` 生效,`fromIndex` / `toIndex` 不生效 —— 只能切前 N 条,不能翻页;
|
|
19
|
+
* - 同一份数据如果另外发布了二维数据源(`DataSource_erwei`),查它只有 1/5 的体积;
|
|
20
|
+
* - CORS 是开的(`Access-Control-Allow-Origin: *`),浏览器里可以直接 POST。
|
|
21
|
+
*
|
|
22
|
+
* 所以默认策略:`.fastjson` + 一次性把**全部字段**取回来(字段名很便宜,model 才是大头),
|
|
23
|
+
* 这样换专题字段时全部命中缓存,不再发请求。
|
|
24
|
+
*/
|
|
25
|
+
export interface AttributeQueryOptions {
|
|
26
|
+
/** 数据服务根地址,形如 https://host/iserver/services/data-xxx/rest/data */
|
|
27
|
+
dataServiceUrl: string;
|
|
28
|
+
/** 数据集,支持 "DataSource:zhoubian" 或只写 "zhoubian"(默认补 DataSource:) */
|
|
29
|
+
datasetName: string;
|
|
30
|
+
/** 与 S3M 单体 ID 对应的字段,默认 SmID(对应 scp 里的 idFieldName) */
|
|
31
|
+
idField?: string;
|
|
32
|
+
/** 只取这些字段,默认取字段表里除几何/索引外的全部(推荐留空,全字段进缓存后换字段零请求) */
|
|
33
|
+
fields?: string[];
|
|
34
|
+
/** 每次请求带多少个 id,默认 200 */
|
|
35
|
+
chunkSize?: number;
|
|
36
|
+
/** 响应格式,默认 'auto':模型数据集用 fastjson(模型是 byte[],hex 比数字数组省 43%),
|
|
37
|
+
* 二维数据集用 json(坐标是 double,hex 反而更胖)。也可以强制指定 */
|
|
38
|
+
format?: 'auto' | 'fastjson' | 'json';
|
|
39
|
+
/** 便于测试时替换,默认用全局 fetch */
|
|
40
|
+
fetchImpl?: typeof fetch;
|
|
41
|
+
}
|
|
42
|
+
export interface AttributeField {
|
|
43
|
+
name: string;
|
|
44
|
+
type?: string;
|
|
45
|
+
alias?: string;
|
|
46
|
+
}
|
|
47
|
+
export type AttributeRow = Record<string, string | number>;
|
|
48
|
+
/** 一次查询的代价,用来在 UI 上展示「查了多大、发了几个请求」 */
|
|
49
|
+
export interface AttributeQueryStats {
|
|
50
|
+
requests: number;
|
|
51
|
+
bytes: number;
|
|
52
|
+
ms: number;
|
|
53
|
+
}
|
|
54
|
+
export declare class AttributeQuery {
|
|
55
|
+
readonly dataServiceUrl: string;
|
|
56
|
+
readonly datasourceName: string;
|
|
57
|
+
readonly datasetName: string;
|
|
58
|
+
readonly idField: string;
|
|
59
|
+
private readonly _fields;
|
|
60
|
+
private readonly _chunkSize;
|
|
61
|
+
private readonly _formatOption;
|
|
62
|
+
private readonly _fetch;
|
|
63
|
+
private readonly _cache;
|
|
64
|
+
private _schema;
|
|
65
|
+
private _resolvedFields;
|
|
66
|
+
private _format;
|
|
67
|
+
private _stats;
|
|
68
|
+
constructor(options: AttributeQueryOptions);
|
|
69
|
+
/** 数据集的 REST 路径:.../datasources/name/{ds}/datasets/name/{name} */
|
|
70
|
+
get datasetPath(): string;
|
|
71
|
+
/** 累计的请求代价(不清零,用来观察整体开销) */
|
|
72
|
+
get stats(): AttributeQueryStats;
|
|
73
|
+
/** 字段表(顺手也用来判断「这个数据集到底有没有属性表」) */
|
|
74
|
+
loadSchema(): Promise<AttributeField[]>;
|
|
75
|
+
/** 已经缓存过、不需要再请求的 id */
|
|
76
|
+
hasCached(smid: number): boolean;
|
|
77
|
+
clearCache(): void;
|
|
78
|
+
/**
|
|
79
|
+
* 按 SmID 批量取属性。自动跳过已缓存的、按 chunkSize 分片,并丢弃几何。
|
|
80
|
+
* 缓存的是**整行**(全部字段),所以换专题字段时不会再发请求。
|
|
81
|
+
*/
|
|
82
|
+
queryBySmids(smids: number[]): Promise<Map<number, AttributeRow>>;
|
|
83
|
+
private _resolveFields;
|
|
84
|
+
/**
|
|
85
|
+
* 选响应格式。
|
|
86
|
+
*
|
|
87
|
+
* 模型数据集的体积几乎全是 `geometry.model`(byte[]),fastjson 用 hex 表示只要 2 字符/字节,
|
|
88
|
+
* json 是十进制数字数组(3~4 字符/字节),所以 fastjson 又快又小;
|
|
89
|
+
* 二维数据集的几何是坐标数组(double),hex 反而比十进制更胖(实测 3.9KB vs 2.4KB/条),
|
|
90
|
+
* 这种就留在 json。用 `features.json` 返回的 geometryType 判断,一次几十字节,跟着实例缓存。
|
|
91
|
+
*/
|
|
92
|
+
private _resolveFormat;
|
|
93
|
+
private _queryChunk;
|
|
94
|
+
private _post;
|
|
95
|
+
private _parse;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=AttributeQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttributeQuery.d.ts","sourceRoot":"","sources":["../../src/core/AttributeQuery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;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AAO,CAAC,eAAe,CAAyB;IAChD,OAAO,CAAC,OAAO,CAAoC;IACnD,OAAO,CAAC,MAAM,CAAyD;gBAE3D,OAAO,EAAE,qBAAqB;IAgB1C,kEAAkE;IAClE,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,4BAA4B;IAC5B,IAAI,KAAK,IAAI,mBAAmB,CAE/B;IAED,kCAAkC;IAC5B,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAU7C,uBAAuB;IACvB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIhC,UAAU,IAAI,IAAI;IAKlB;;;OAGG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YAuBzD,cAAc;IAY5B;;;;;;;OAOG;YACW,cAAc;YAgBd,WAAW;YAsCX,KAAK;IAenB,OAAO,CAAC,MAAM;CAGf"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* iServer 数据服务属性查询
|
|
3
|
+
*
|
|
4
|
+
* S3M 瓦片里**只有单体 ID**(`MonomerIDInfo.id`,即 SmID)和顶点区间,没有任何业务字段;
|
|
5
|
+
* 业务属性在 iServer 的「数据服务」里:同一份数据源被发布成 `data-xxx/rest/data` 的那个服务。
|
|
6
|
+
*
|
|
7
|
+
* 这里的职责只有一件事:按 SmID 批量取字段值。字段表、分片、缓存、去重都在内部消化,
|
|
8
|
+
* 上层(`S3MLayer.colorByField`)只关心「拿到值之后怎么算颜色」。
|
|
9
|
+
*
|
|
10
|
+
* 实测(iServer 2026,GEOMODEL3D 数据集):
|
|
11
|
+
* - `queryOption: 'ATTRIBUTE'` 被忽略:放 body、放 query string、大小写都没用,
|
|
12
|
+
* 2D / 3D 数据集都照样返回几何;模型数据集还会给每条要素带上 `geometry.model`
|
|
13
|
+
* —— 那是 deflate 压缩后的 S3M 模型字节,约 2.5KB/条,占整个响应的 90%;
|
|
14
|
+
* - 没有「只取属性」的接口。想省带宽只能逐条 GET `/rest/data/feature/{a}-{b}-{idx}.json`
|
|
15
|
+
* (957B/条,model 为 null),但那是拿请求数换带宽:300 条并发 16 反而比一次 POST 慢;
|
|
16
|
+
* - `.fastjson` 比 `.json` 少 40%:model 用 hex(2 字符/字节)而不是数字数组(3~4 字符/字节)。
|
|
17
|
+
* 代价是它不是严格 JSON(`0.0D`、`1L`、`x'ABCD'` 都是 Java 字面量),要先清洗;
|
|
18
|
+
* - `maxFeatures` 生效,`fromIndex` / `toIndex` 不生效 —— 只能切前 N 条,不能翻页;
|
|
19
|
+
* - 同一份数据如果另外发布了二维数据源(`DataSource_erwei`),查它只有 1/5 的体积;
|
|
20
|
+
* - CORS 是开的(`Access-Control-Allow-Origin: *`),浏览器里可以直接 POST。
|
|
21
|
+
*
|
|
22
|
+
* 所以默认策略:`.fastjson` + 一次性把**全部字段**取回来(字段名很便宜,model 才是大头),
|
|
23
|
+
* 这样换专题字段时全部命中缓存,不再发请求。
|
|
24
|
+
*/
|
|
25
|
+
const DEFAULT_ID_FIELD = 'SmID';
|
|
26
|
+
const DEFAULT_CHUNK_SIZE = 200;
|
|
27
|
+
/** 几何/索引字段取回来没用,还特别占带宽 */
|
|
28
|
+
const SKIP_FIELDS = new Set(['smgeometry', 'smindexkey', 'smgeoposition']);
|
|
29
|
+
/**
|
|
30
|
+
* fastjson 不是严格 JSON,服务端会把 Java 字面量直接吐出来:
|
|
31
|
+
* `"model":x'D7A34040...'`(byte[] 的 hex)、`"rotationX":0.0D`、`"id":423L`
|
|
32
|
+
* 这些在 JSON.parse 里全是语法错误。model 恰好是我们唯一不想要的东西(占 90% 体积),
|
|
33
|
+
* 直接在字符串上抹掉,连解析都省了。
|
|
34
|
+
*/
|
|
35
|
+
function sanitizeFastjson(text) {
|
|
36
|
+
return text
|
|
37
|
+
.replace(/x'[0-9A-Fa-f]*'/g, 'null')
|
|
38
|
+
.replace(/(\d)[dDlLfF](?=\s*[,}\]])/g, '$1');
|
|
39
|
+
}
|
|
40
|
+
export class AttributeQuery {
|
|
41
|
+
dataServiceUrl;
|
|
42
|
+
datasourceName;
|
|
43
|
+
datasetName;
|
|
44
|
+
idField;
|
|
45
|
+
_fields;
|
|
46
|
+
_chunkSize;
|
|
47
|
+
_formatOption;
|
|
48
|
+
_fetch;
|
|
49
|
+
_cache = new Map();
|
|
50
|
+
_schema = null;
|
|
51
|
+
_resolvedFields = null;
|
|
52
|
+
_format = null;
|
|
53
|
+
_stats = { requests: 0, bytes: 0, ms: 0 };
|
|
54
|
+
constructor(options) {
|
|
55
|
+
if (!options?.dataServiceUrl)
|
|
56
|
+
throw new Error('[s3m] AttributeQuery 缺少 dataServiceUrl');
|
|
57
|
+
const full = options.datasetName?.includes(':') ? options.datasetName : `DataSource:${options.datasetName ?? ''}`;
|
|
58
|
+
const [ds, name] = full.split(':');
|
|
59
|
+
if (!name)
|
|
60
|
+
throw new Error(`[s3m] datasetName 格式应为 "数据源:数据集",收到 "${options.datasetName}"`);
|
|
61
|
+
this.dataServiceUrl = options.dataServiceUrl.replace(/\/+$/, '');
|
|
62
|
+
this.datasourceName = ds;
|
|
63
|
+
this.datasetName = name;
|
|
64
|
+
this.idField = options.idField ?? DEFAULT_ID_FIELD;
|
|
65
|
+
this._fields = options.fields?.length ? options.fields : null;
|
|
66
|
+
this._chunkSize = Math.max(1, options.chunkSize ?? DEFAULT_CHUNK_SIZE);
|
|
67
|
+
this._formatOption = options.format ?? 'auto';
|
|
68
|
+
this._fetch = options.fetchImpl ?? globalThis.fetch.bind(globalThis);
|
|
69
|
+
}
|
|
70
|
+
/** 数据集的 REST 路径:.../datasources/name/{ds}/datasets/name/{name} */
|
|
71
|
+
get datasetPath() {
|
|
72
|
+
return `${this.dataServiceUrl}/datasources/name/${encodeURIComponent(this.datasourceName)}/datasets/name/${encodeURIComponent(this.datasetName)}`;
|
|
73
|
+
}
|
|
74
|
+
/** 累计的请求代价(不清零,用来观察整体开销) */
|
|
75
|
+
get stats() {
|
|
76
|
+
return { ...this._stats };
|
|
77
|
+
}
|
|
78
|
+
/** 字段表(顺手也用来判断「这个数据集到底有没有属性表」) */
|
|
79
|
+
async loadSchema() {
|
|
80
|
+
if (this._schema)
|
|
81
|
+
return this._schema;
|
|
82
|
+
const res = await this._fetch(`${this.datasetPath}/fields.json`);
|
|
83
|
+
this._stats.requests++;
|
|
84
|
+
if (!res.ok)
|
|
85
|
+
throw new Error(`[s3m] 读取字段表失败 ${res.status}:${this.datasetPath}/fields.json`);
|
|
86
|
+
const json = (await res.json());
|
|
87
|
+
this._schema = (json.fieldNames ?? []).map((name) => ({ name }));
|
|
88
|
+
return this._schema;
|
|
89
|
+
}
|
|
90
|
+
/** 已经缓存过、不需要再请求的 id */
|
|
91
|
+
hasCached(smid) {
|
|
92
|
+
return this._cache.has(smid);
|
|
93
|
+
}
|
|
94
|
+
clearCache() {
|
|
95
|
+
this._cache.clear();
|
|
96
|
+
this._stats = { requests: 0, bytes: 0, ms: 0 };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 按 SmID 批量取属性。自动跳过已缓存的、按 chunkSize 分片,并丢弃几何。
|
|
100
|
+
* 缓存的是**整行**(全部字段),所以换专题字段时不会再发请求。
|
|
101
|
+
*/
|
|
102
|
+
async queryBySmids(smids) {
|
|
103
|
+
const ids = [...new Set(smids.filter((n) => Number.isFinite(n)))];
|
|
104
|
+
const result = new Map();
|
|
105
|
+
for (const id of ids) {
|
|
106
|
+
const hit = this._cache.get(id);
|
|
107
|
+
if (hit)
|
|
108
|
+
result.set(id, hit);
|
|
109
|
+
}
|
|
110
|
+
const todo = ids.filter((id) => !this._cache.has(id));
|
|
111
|
+
if (!todo.length)
|
|
112
|
+
return result;
|
|
113
|
+
const fields = await this._resolveFields();
|
|
114
|
+
for (let i = 0; i < todo.length; i += this._chunkSize) {
|
|
115
|
+
const chunk = todo.slice(i, i + this._chunkSize);
|
|
116
|
+
const rows = await this._queryChunk(chunk, fields);
|
|
117
|
+
for (const [id, row] of rows) {
|
|
118
|
+
this._cache.set(id, row);
|
|
119
|
+
result.set(id, row);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
async _resolveFields() {
|
|
125
|
+
if (this._resolvedFields)
|
|
126
|
+
return this._resolvedFields;
|
|
127
|
+
if (this._fields) {
|
|
128
|
+
this._resolvedFields = this._fields;
|
|
129
|
+
return this._resolvedFields;
|
|
130
|
+
}
|
|
131
|
+
const schema = await this.loadSchema();
|
|
132
|
+
const fields = schema.map((f) => f.name).filter((n) => !SKIP_FIELDS.has(n.toLowerCase()));
|
|
133
|
+
this._resolvedFields = fields.length ? fields : [this.idField];
|
|
134
|
+
return this._resolvedFields;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* 选响应格式。
|
|
138
|
+
*
|
|
139
|
+
* 模型数据集的体积几乎全是 `geometry.model`(byte[]),fastjson 用 hex 表示只要 2 字符/字节,
|
|
140
|
+
* json 是十进制数字数组(3~4 字符/字节),所以 fastjson 又快又小;
|
|
141
|
+
* 二维数据集的几何是坐标数组(double),hex 反而比十进制更胖(实测 3.9KB vs 2.4KB/条),
|
|
142
|
+
* 这种就留在 json。用 `features.json` 返回的 geometryType 判断,一次几十字节,跟着实例缓存。
|
|
143
|
+
*/
|
|
144
|
+
async _resolveFormat() {
|
|
145
|
+
if (this._format)
|
|
146
|
+
return this._format;
|
|
147
|
+
if (this._formatOption !== 'auto')
|
|
148
|
+
return (this._format = this._formatOption);
|
|
149
|
+
try {
|
|
150
|
+
const res = await this._fetch(`${this.datasetPath}/features.json?fromIndex=0&toIndex=1`);
|
|
151
|
+
this._stats.requests++;
|
|
152
|
+
const json = (await res.json());
|
|
153
|
+
const isModel = String(json.geometryType ?? '').toUpperCase().includes('MODEL');
|
|
154
|
+
this._format = isModel ? 'fastjson' : 'json';
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
// 探测失败就当模型数据集处理:S3M 场景下这是绝大多数
|
|
158
|
+
this._format = 'fastjson';
|
|
159
|
+
}
|
|
160
|
+
return this._format;
|
|
161
|
+
}
|
|
162
|
+
async _queryChunk(ids, fields) {
|
|
163
|
+
const body = {
|
|
164
|
+
getFeatureMode: 'SQL',
|
|
165
|
+
datasetNames: [`${this.datasourceName}:${this.datasetName}`],
|
|
166
|
+
// 服务端会忽略它,但留着:将来遇到真的听话的版本就能省下全部几何
|
|
167
|
+
queryOption: 'ATTRIBUTE',
|
|
168
|
+
queryParameter: {
|
|
169
|
+
attributeFilter: `${this.idField} IN (${ids.join(',')})`,
|
|
170
|
+
fields,
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
const format = await this._resolveFormat();
|
|
174
|
+
const raw = await this._post(body, format);
|
|
175
|
+
let json;
|
|
176
|
+
try {
|
|
177
|
+
json = this._parse(raw);
|
|
178
|
+
}
|
|
179
|
+
catch (e) {
|
|
180
|
+
// fastjson 的方言没吃透时留一条退路,别让一次格式变更把功能整个弄挂
|
|
181
|
+
if (format !== 'fastjson')
|
|
182
|
+
throw e;
|
|
183
|
+
json = this._parse(await this._post(body, 'json'));
|
|
184
|
+
}
|
|
185
|
+
if (json.error)
|
|
186
|
+
throw new Error(`[s3m] 属性查询失败:${json.error.errorMsg ?? '未知错误'}`);
|
|
187
|
+
const out = new Map();
|
|
188
|
+
for (const f of json.features ?? []) {
|
|
189
|
+
const names = f.fieldNames ?? [];
|
|
190
|
+
const values = f.fieldValues ?? [];
|
|
191
|
+
const row = {};
|
|
192
|
+
for (let i = 0; i < names.length; i++)
|
|
193
|
+
row[names[i]] = values[i];
|
|
194
|
+
// 优先用 idField(SmID)关联,拿不到才退回要素 ID
|
|
195
|
+
const rawId = row[this.idField] ?? f.ID;
|
|
196
|
+
const id = Number(rawId);
|
|
197
|
+
if (Number.isFinite(id))
|
|
198
|
+
out.set(id, row);
|
|
199
|
+
}
|
|
200
|
+
return out;
|
|
201
|
+
}
|
|
202
|
+
async _post(body, format) {
|
|
203
|
+
const t0 = performance.now();
|
|
204
|
+
const res = await this._fetch(`${this.dataServiceUrl}/featureResults.${format}?returnContent=true`, {
|
|
205
|
+
method: 'POST',
|
|
206
|
+
headers: { 'Content-Type': 'application/json' },
|
|
207
|
+
body: JSON.stringify(body),
|
|
208
|
+
});
|
|
209
|
+
const text = await res.text();
|
|
210
|
+
this._stats.requests++;
|
|
211
|
+
this._stats.bytes += text.length;
|
|
212
|
+
this._stats.ms += Math.round(performance.now() - t0);
|
|
213
|
+
if (!res.ok)
|
|
214
|
+
throw new Error(`[s3m] 属性查询失败 ${res.status}:${text.slice(0, 200)}`);
|
|
215
|
+
return text;
|
|
216
|
+
}
|
|
217
|
+
_parse(text) {
|
|
218
|
+
return JSON.parse(text.includes("x'") || /\d[dDlL](?=\s*[,}\]])/.test(text) ? sanitizeFastjson(text) : text);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=AttributeQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttributeQuery.js","sourceRoot":"","sources":["../../src/core/AttributeQuery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,0BAA0B;AAC1B,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC;AA6C3E;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO,IAAI;SACR,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC;SACnC,OAAO,CAAC,4BAA4B,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,OAAO,cAAc;IAChB,cAAc,CAAS;IACvB,cAAc,CAAS;IACvB,WAAW,CAAS;IACpB,OAAO,CAAS;IAER,OAAO,CAAkB;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* - 多处需要按 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"}
|