You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 11KB

2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. ---
  2. sidebar: auto
  3. ---
  4. # Effects 🌎
  5. Add dynamic elements to the 3D scene to allow the scene to move and run more closely to the real world
  6. ## DC.Weather
  7. ### example
  8. ```js
  9. let weather = new DC.Weather(viewer)
  10. ```
  11. ### creation
  12. - **_constructor()_**
  13. - Returns `weather`
  14. ### properties
  15. - [`{Rain} rain`](#rain)**_`readonly`_**
  16. - [`{Snow} snow`](#snow) **_`readonly`_**
  17. - [`{Fog} snow`](#fog) **_`readonly`_**
  18. - [`{Cloud} cloud`](#cloud) **_`readonly`_**
  19. ## Rain
  20. ### example
  21. ```js
  22. viewer.weather.rain.enable = true
  23. viewer.weather.rain.speed = 2
  24. ```
  25. ### properties
  26. - `{Boolean} enable`
  27. - `{Number} speed`
  28. ## Snow
  29. ### example
  30. ```js
  31. viewer.weather.snow.enable = true
  32. viewer.weather.snow.speed = 2
  33. ```
  34. ### properties
  35. - `{Boolean} enable`
  36. - `{Number} speed`
  37. ## Fog
  38. ### example
  39. ```js
  40. viewer.weather.fog.enable = true
  41. viewer.weather.fog.fogColor = DC.Color.BLACK
  42. ```
  43. ### properties
  44. - `{Boolean} enable`
  45. - `{Color} fogColor
  46. - `{Object} fogByDistance`: { near: 10, nearValue: 0, far: 2000, farValue: 1.0 }
  47. ## Cloud
  48. ### example
  49. ```js
  50. viewer.weather.cloud.enable = true
  51. viewer.weather.cloud.rotateAmount = 0.02
  52. ```
  53. ### properties
  54. - `{Boolean} enable`
  55. - `{Number} rotateAmount`
  56. ## DC.Effect
  57. ### example
  58. ```js
  59. let effect = new DC.Effect()
  60. viewer.use(effect)
  61. ```
  62. ### creation
  63. - **_constructor()_**
  64. - Returns `effect`
  65. ### properties
  66. - [`{BlackAndWhite} blackAndWhite`](#blackandwhite) **_`readonly`_**
  67. - [`{Bloom} bloom`](#bloom) **_`readonly`_**
  68. - [`{Brightness} brightness`](#brightness)**_`readonly`_**
  69. - [`{DepthOfField} depthOfField`](#depthoffield) **_`readonly`_**
  70. - [`{LensFlare} lensFlare`](#lensflare) **_`readonly`_**
  71. - [`{Night} night`](#night) **_`readonly`_**
  72. - [`{Silhouette} silhouette`](#silhouette) **_`readonly`_**
  73. ## BlackAndWhite
  74. ### example
  75. ```js
  76. viewer.effect.blackAndWhite.enable = true
  77. ```
  78. ### properties
  79. - `{Boolean} enable`
  80. - `{Number} gradations`
  81. - `{Array} selected`
  82. ## Bloom
  83. ### example
  84. ```js
  85. viewer.effect.bloom.enable = true
  86. ```
  87. ### properties
  88. - `{Boolean} enable`
  89. - `{Number} contrast`
  90. - `{Number} brightness`
  91. - `{Number} glowOnly`
  92. - `{Number} delta`
  93. - `{Number} sigma`
  94. - `{Number} stepSize`
  95. - `{Array} selected`
  96. ## Brightness
  97. ### example
  98. ```js
  99. viewer.effect.brightness.enable = true
  100. ```
  101. ### properties
  102. - `{Boolean} enable`
  103. - `{Number} intensity`
  104. - `{Array} selected`
  105. ## DepthOfField
  106. ### example
  107. ```js
  108. viewer.effect.depthOfField.enable = true
  109. ```
  110. ### properties
  111. - `{Boolean} enable`
  112. - `{Number}} focalDistance`
  113. - `{Number} delta`
  114. - `{Number} sigma`
  115. - `{Number} stepSize`
  116. - `{Array} selected`
  117. ## LensFlare
  118. ### example
  119. ```js
  120. viewer.effect.lensFlare.enable = true
  121. ```
  122. ### properties
  123. - `{Boolean} enable`
  124. - `{Number}} intensity`
  125. - `{Number} distortion`
  126. - `{Number} dirtAmount`
  127. - `{Number} haloWidth`
  128. - `{Array} selected`
  129. ## Night
  130. ### example
  131. ```js
  132. viewer.effect.night.enable = true
  133. ```
  134. ### properties
  135. - `{Boolean} enable`
  136. - `{Array} selected`
  137. ## Silhouette
  138. ### example
  139. ```js
  140. viewer.effect.silhouette.enable = true
  141. ```
  142. ### properties
  143. - `{Boolean} enable`
  144. - `{Color} color`
  145. - `{Number} length`
  146. - `{Array} selected`
  147. ## Animation
  148. > Animation base class
  149. :::warning
  150. The class cannot be instantiated
  151. :::
  152. ### methods
  153. - **_start()_**
  154. - returns `this`
  155. - **_stop()_**
  156. - returns `this`
  157. ## DC.AroundPoint
  158. > Inherited from [Animation](#animation)
  159. ### example
  160. ```js
  161. let aroundPoint = new DC.AroundPoint(viewer, '120.121, 31.12')
  162. aroundPoint.start()
  163. ```
  164. ### creation
  165. - **_constructor(viewer,position,[options])_**
  166. - parameters
  167. - `{Viewer} viewer`
  168. - `{Position|String|Array} position`
  169. - `{Object} options`
  170. - returns `aroundPoint`
  171. ```json
  172. //options(optional)
  173. {
  174. "heading": 0,
  175. "pitch": 0,
  176. "range": 0,
  177. "duration": 0,
  178. "callback": null,
  179. "context": null
  180. }
  181. ```
  182. ## DC.AroundView
  183. > Inherited from [Animation](#animation)
  184. ### example
  185. ```js
  186. let aroundView = new DC.AroundView(viewer)
  187. aroundView.start()
  188. ```
  189. ### creation
  190. - **_constructor(viewer,options)_**
  191. - parameters
  192. - `{Viewer} viewer`
  193. - `{Object} options`
  194. - returns `aroundView`
  195. ```json
  196. //options(optional)
  197. {
  198. "heading": 0,
  199. "duration": 0,
  200. "pitch": 0,
  201. "roll": 0,
  202. "callback": null,
  203. "context": null
  204. }
  205. ```
  206. ## DC.CircleScan
  207. > Inherited from [Animation](#animation)
  208. ### example
  209. ```js
  210. let circleScan = new DC.CircleScan(viewer, '120, 20', 200)
  211. circleScan.start()
  212. ```
  213. ### creation
  214. - **_constructor(viewer,position,radius,[options])_**
  215. - parameters
  216. - `{Viewer} viewer`:场景
  217. - `{DC.Position} position`:位置
  218. - `{Number} radius`:半径
  219. - `{Object} options`:属性
  220. - returns `circleScan`
  221. ```json
  222. //options(optional)
  223. {
  224. "color": DC.Color.BLUE,
  225. "speed": 5
  226. }
  227. ```
  228. ## DC.Flying
  229. > Inherited from [Animation](#animation)
  230. ### example
  231. ```js
  232. let flying = new DC.Flying(viewer)
  233. flying.positions = ['121.234,21.212,0,-29', '121.435,21.212,0,-29']
  234. flying.start()
  235. ```
  236. ### creation
  237. - **_constructor(viewer,options)_**
  238. - parameters
  239. - `{Viewer} viewer`:场景
  240. - `{Object} options`:options
  241. - returns `flying`
  242. ```json
  243. //options(optional)
  244. {
  245. "loop": false,
  246. "dwellTime": 3,
  247. "callback": null
  248. }
  249. ```
  250. ### properties
  251. - `{Array} positions`
  252. - `{Array} durations`: The flight interval of each point, when the length of the array is 1, each interval is the same, if not 1, the length must be equal to the length of the point
  253. ### methods
  254. - **_start()_**
  255. - returns `this`
  256. - **_pause()_**
  257. - returns `this`
  258. - **_restore()_**
  259. - returns `this`
  260. ## DC.GlobeRotate
  261. > Inherited from [Animation](#animation)
  262. ### example
  263. ```js
  264. let globeRotate = new DC.GlobeRotate(viewer, {
  265. duration: 5,
  266. speed: 1000,
  267. callback: () => {},
  268. })
  269. globeRotate.start()
  270. ```
  271. ### creation
  272. - **_constructor(viewer,[options])_**
  273. - parameters
  274. - `{DC.Viewer} viewer`
  275. - `{Object} options`
  276. - returns `globeRotate`
  277. ```json
  278. //options(optional)
  279. {
  280. "speed": 12 * 1000,
  281. "duration": 0,
  282. "callback": null,
  283. "context": null
  284. }
  285. ```
  286. ## DC.RadarScan
  287. > Inherited from [Animation](#animation)
  288. ### example
  289. ```js
  290. let radarScan = new DC.RadarScan(viewer, '120, 20', 200)
  291. radarScan.start()
  292. ```
  293. ### creation
  294. - **_constructor(viewer,position,radius,options)_**
  295. - parameters
  296. - `{Viewer} viewer`
  297. - `{DC.Position} position`
  298. - `{Number} radius`
  299. - `{Object} options`
  300. - returns `radarScan`
  301. ```json
  302. //options(optional)
  303. {
  304. "color": DC.Color.BLUE,
  305. "speed": 5
  306. }
  307. ```
  308. ## DC.RoamingController
  309. ### example
  310. ```js
  311. let rc = new DC.RoamingController(viewer)
  312. ```
  313. ### creation
  314. - **_constructor(viewer)_**
  315. - parameters
  316. - `{Viewer} viewer`
  317. - returns `roamingController`
  318. ### methods
  319. - **_addPath(path)_**
  320. - parameters
  321. - `{RoamingPath} path`
  322. - returns `this`
  323. - **_addPaths(paths)_**
  324. - parameters
  325. - `{Array<RoamingPath>} paths`
  326. - returns `this`
  327. - **_removePath(path)_**
  328. - parameters
  329. - `{RoamingPath} path`
  330. - returns `path`
  331. - **_getPath(id)_**
  332. - parameters
  333. - `{String} id`
  334. - returns `path`
  335. - **_getPaths()_**
  336. - returns `array`
  337. - **_activate(path, viewOption)_**
  338. - parameters
  339. - `{RoamingPath} path`
  340. - `{String} viewOption`
  341. - returns `this`
  342. ```json
  343. // options (optional)
  344. {
  345. "pitch": 0,
  346. "range": 1000
  347. }
  348. ```
  349. - **_deactivate()_**
  350. - returns `this`
  351. - **_clear()_**
  352. - returns `this`
  353. ## DC.RoamingPath
  354. ### example
  355. ```js
  356. let path = new DC.RoamingPath('120.121,32.1213;121.132,32.1213', 20)
  357. rc.addPath(path)
  358. ```
  359. ### creation
  360. - **_constructor(positions, duration, [pathMode])_**
  361. - parameters
  362. - `{String|Array<Position|Number|String|Object>} positions`
  363. - `{Number} duration`
  364. - `{String} pathMode` speed / time
  365. - returns `roamingPath`
  366. ### properties
  367. - `{String} pathId` **_`readonly`_**
  368. - `{String} id`
  369. - `{String|Array<Position|Number|String>} positions`
  370. - `{Number} duration`
  371. - `{String} pathMode` speed / time
  372. - `{String} state` **_`readonly`_**
  373. ## DC.KeyboardRoaming
  374. ### example
  375. ```js
  376. let kr = new DC.KeyboardRoaming(viewer)
  377. kr.enable = true
  378. ```
  379. ### creation
  380. - **_constructor(viewer)_**
  381. - parameters
  382. - `{Viewer} viewer`
  383. - returns `keyboardRoaming`
  384. ### properties
  385. - `{Boolean} enable`
  386. - `{Number} moveRate` default: 100
  387. - `{Number} rotateRate` default: 0.01
  388. ## DC.TrackController
  389. ### example
  390. ```js
  391. let tc = new DC.TrackController(viewer)
  392. ```
  393. ### creation
  394. - **_constructor(viewer)_**
  395. - parameters
  396. - `{Viewer} viewer`
  397. - returns `trackController`
  398. ### methods
  399. - **_addTrack(track)_**
  400. - parameters
  401. - `{Track} track`
  402. - returns `this`
  403. - **_addTracks(tracks)_**
  404. - parameters
  405. - `{Array<Track>} tracks`
  406. - returns `this`
  407. - **_removeTrack(track)_**
  408. - parameters
  409. - `{Track} track`
  410. - returns `path`
  411. - **_getTrack(id)_**
  412. - parameters
  413. - `{String} id`
  414. - returns `track`
  415. - **_getTracks()_**
  416. - returns `array`
  417. - **_play()_**
  418. - returns `this`
  419. - **_pause()_**
  420. - returns `this`
  421. - **_restore()_**
  422. - returns `this`
  423. - **_viewTrack(track, viewOption)_**
  424. - parameters
  425. - `{Track} track`
  426. - `{String} viewOption`
  427. - returns `this`
  428. ```json
  429. // options (optional)
  430. {
  431. "mode": null, // DC.TrackViewMode
  432. "pitch": 0,
  433. "range": 1000
  434. }
  435. ```
  436. - **_releaseTrack(track)_**
  437. - parameters
  438. - `{Track} track`:路径
  439. - returns `this`
  440. - **_clear()_**
  441. - returns `this`
  442. ## DC.Track
  443. ### example
  444. ```js
  445. let track = new DC.Track('120.121,32.1213;121.132,32.1213', 20)
  446. rc.addTrack(track)
  447. ```
  448. ### creation
  449. - **_constructor(positions, duration, [callback], [options])_**
  450. - parameters
  451. - `{String|Array<Position|Number|String|Object>} positions`
  452. - `{Number} duration`
  453. - `{Function} callback`:Each point arrival callback function, parameters are: position, isLast
  454. - `{Object} options`
  455. - returns `track`
  456. ```json
  457. // options (optional)
  458. {
  459. "clampToGround": false,
  460. "clampToTileset": false,
  461. "interpolationType": "Linear", // Linear、Hermite、Lagrange
  462. "interpolationDegree": 2,
  463. "endDelayTime": 0.5 // End time extension time, unit:second
  464. }
  465. ```
  466. ### properties
  467. - `{String} trackId` **_`readonly`_**
  468. - `{String} id`
  469. - `{String|Array<Position|Number|String|Object>} positions`
  470. - `{Number} duration`
  471. - `{Date} startTime`
  472. - `{String} state` **_`readonly`_**
  473. ### methods
  474. - **_addPosition(position,duration)_**
  475. - parameters
  476. - `{Position|Array|String|Object} position`
  477. - `{Number} duration`
  478. - returns `this`
  479. - **_setModel(modelUrl,style)_**
  480. - parameters
  481. - `{String} modelPath`
  482. - `{Object} style` [DC.Model](../dc-sdk/#dc-model)
  483. - returns `this`
  484. - **_setBillboard(icon,style)_**
  485. - parameters
  486. - `{String} icon`
  487. - `{Object} style` [DC.Billboard](../dc-sdk/#dc-billboard)
  488. - returns `this`
  489. - **_setLabel(text,style)_**
  490. - parameters
  491. - `{String} text`
  492. - `{Object} style` [DC.Label](../dc-sdk/#dc-label)
  493. - returns `this`
  494. - **_setPath(visible,style)_**
  495. - parameters
  496. - `{Boolean}} visible`
  497. - `{Object} style` [DC.Polyline](../dc-sdk/#dc-polyline)
  498. - returns `this`