Skip to content

Commit 12fdec6

Browse files
authored
Docs by vitepress (#657)
* docs by vitepress * update * fix Boxs missing default options * update docs
1 parent 73507d6 commit 12fdec6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1794
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ node_modules
4848
examples/replace.json
4949
json/*
5050
dist/*
51+
.vitepress/cache
52+
docs/.vitepress/cache

docs/.vitepress/config.mjs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { defineConfig } from 'vitepress'
2+
3+
// https://vitepress.dev/reference/site-config
4+
export default defineConfig({
5+
title: "🌐maptalks.three",
6+
description: "A maptalks layer to render with three.js.",
7+
base: '/maptalks.three/docs/',
8+
markdown: {
9+
image: {
10+
// 默认禁用;设置为 true 可为所有图片启用懒加载。
11+
lazyLoading: true
12+
}
13+
},
14+
themeConfig: {
15+
// https://vitepress.dev/reference/default-theme-config
16+
nav: [
17+
{ text: 'Start', link: '/start/install.md' },
18+
{ text: 'API', link: '/api/index.md' },
19+
{ text: 'Questions', link: '/questions/index.md' },
20+
{ text: 'Examples', link: 'https://maptalks.org/maptalks.three/demo/index.html' },
21+
],
22+
23+
sidebar: {
24+
'/start/': [
25+
{ text: 'Install', link: '/start/install.md' },
26+
{ text: 'Hello World', link: '/start/helloworld.md' },
27+
{ text: 'Design Target', link: '/start/target.md' },
28+
{ text: 'Custom BaseObject', link: '/start/custom.md' },
29+
{ text: 'Some Links', link: '/start/links.md' },
30+
],
31+
'/api/': [
32+
{ text: 'Some Types', link: '/api/types.md' },
33+
{ text: 'BaseObject', link: '/api/baseobject.md' },
34+
{ text: 'ThreeLayer', link: '/api/threelayer.md' }
35+
]
36+
},
37+
38+
socialLinks: [
39+
{ icon: 'github', link: 'https://github.com/maptalks/maptalks.three' }
40+
],
41+
lastUpdated: true,
42+
search: {
43+
provider: 'local'
44+
}
45+
}
46+
})

docs/api/baseobject.md

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# BaseObject
6+
7+
It is a super base class.
8+
9+
Its subclasses include:
10+
11+
```
12+
├─ Bar.ts
13+
├─ Bars.ts
14+
├─ Box.ts
15+
├─ Boxs.ts
16+
├─ ExtrudeLine.ts
17+
├─ ExtrudeLines.ts
18+
├─ ExtrudeLineTrail.ts
19+
├─ ExtrudePolygon.ts
20+
├─ ExtrudePolygons.ts
21+
├─ FatLine.ts
22+
├─ FatLines.ts
23+
├─ HeatMap.ts
24+
├─ Line.ts
25+
├─ Lines.ts
26+
├─ Model.ts
27+
├─ Path.ts
28+
├─ Paths.ts
29+
├─ Point.ts
30+
├─ Points.ts
31+
├─ Terrain.ts
32+
```
33+
34+
Its API and maptalks Geometry is very similar
35+
36+
## constructor()
37+
38+
Usually, we directly use its subclasses
39+
40+
```js
41+
const baseObject = new BaseObject(id);
42+
```
43+
44+
## methods
45+
46+
### `_initOptions(options: Record<string, any>)`
47+
48+
init BaseObject inner config <Badge type="tip" text="for custom" />
49+
50+
```js
51+
this._initOptions(options);
52+
```
53+
54+
### `_createMesh(geometry, material)`
55+
56+
create inner `THREE.Mesh` <Badge type="tip" text="for custom" />
57+
58+
```js
59+
const geometry = new THREE.CircleBufferGeometry(r, 50);
60+
61+
//Initialize internal object3d
62+
// https://github.com/maptalks/maptalks.three/blob/1e45f5238f500225ada1deb09b8bab18c1b52cf2/src/BaseObject.js#L140
63+
this._createMesh(geometry, material);
64+
```
65+
66+
### `_createGroup()`
67+
68+
create inner `THREE.Group` <Badge type="tip" text="for custom" />
69+
70+
### `_createLine(geometry, material)`
71+
72+
create inner `THREE.Line`
73+
74+
### `_createPoints(geometry, material)`
75+
76+
create inner `THREE.Points` <Badge type="tip" text="for custom" />
77+
78+
### `_createLineSegments(geometry, material)`
79+
80+
create inner `THREE.LineSegments` <Badge type="tip" text="for custom" />
81+
82+
### `_createInstancedMesh(geometry, material, count)`
83+
84+
create inner `THREE.InstancedMesh` <Badge type="tip" text="for custom" />
85+
86+
### `getObject3d()`
87+
88+
get inner `THREE.Object3d` , `THREE.Mesh` , `THREE.Group` etc
89+
90+
### `getOptions()`
91+
92+
get BaseObject options config
93+
94+
### `addTo(threeLayer)`
95+
96+
### `remove()`
97+
98+
### `getId()`
99+
100+
### `setId(id:string)`
101+
102+
### `getProperties()`
103+
104+
### `setProperties(props: Record<string, any>)`
105+
106+
### `getLayer(): ThreeLayer`
107+
108+
### `getMap(): Map`
109+
110+
### `getCenter(): Coordinate|null`
111+
112+
### `getAltitude():number`
113+
114+
### `setAltitude(altitude: number)`
115+
116+
### `getHeight():number`
117+
118+
### `setHeight(height: number)`
119+
120+
### `show()`
121+
122+
### `hide()`
123+
124+
### `isVisible():boolean`
125+
126+
### `setInfoWindow(options)`
127+
128+
```js
129+
// //infowindow test
130+
bar.setInfoWindow({
131+
content: 'hello world,height:' + d.height * 400,
132+
title: 'message',
133+
animationDuration: 0
134+
});
135+
```
136+
137+
### `getInfoWindow()`
138+
139+
### `openInfoWindow(coordinate)`
140+
141+
### `closeInfoWindow()`
142+
143+
### `removeInfoWindow()`
144+
145+
### `setToolTip(content, options)`
146+
147+
```js
148+
// // tooltip test
149+
bar.setToolTip(d.height * 400, {
150+
showTimeout: 0,
151+
eventsPropagation: true,
152+
dx: 10
153+
});
154+
```
155+
156+
### `getToolTip()`
157+
158+
### `closeToolTip()`
159+
160+
### `removeToolTip()`
161+
162+
### `getMinZoom()`
163+
164+
### `getMaxZoom()`
165+
166+
### `isAsynchronous()`
167+
168+
Is it asynchronous, that is, constructing graphic data through workers
169+
170+
### `on(eventName, handler, context)`
171+
172+
```js
173+
const clickHandler = (e) => {
174+
175+
}
176+
bar.on('click', clickHandler);
177+
```
178+
179+
### `once(eventName, handler, context)`
180+
181+
```js
182+
bar.once('click', clickHandler);
183+
```
184+
185+
### `off(eventName, handler, context)`
186+
187+
```js
188+
bar.off('click', clickHandler);
189+
```
190+
191+
## events
192+
193+
```js
194+
const clickHandler = (e) => {
195+
196+
}
197+
bar.on('click mousemove', clickHandler);
198+
```
199+
200+
### add
201+
202+
### remove
203+
204+
### click
205+
206+
### mousemove
207+
208+
### mouseover
209+
210+
### mouseout
211+
212+
### dblclick
213+
214+
### empty
215+
216+
### idchange
217+
218+
### propertieschange
219+
220+
### show
221+
222+
### hide
223+
224+
### symbolchange
225+
226+
### workerload
227+
228+
::: warning
229+
This event will only be triggered by constructing graphic data through workers
230+
:::

docs/api/index.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# API
6+
7+
maptalks.three Mainly provides two exported variables
8+
9+
* `BaseObject`
10+
11+
Graphic super base class, all graphics will be based on it
12+
13+
* `ThreeLayer`
14+
15+
A maptalks Layer to render with three.js
16+
17+
::: warning
18+
19+
When you read the documentation, you should be familiar with the documentation for maptalks.js and three.js
20+
21+
:::

0 commit comments

Comments
 (0)