• Stars
    star
    171
  • Rank 222,266 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⚡ Vite plugin for Cesium

vite-plugin-cesium

npm npm

Easily set up a Cesium project in Vite.

update: if you just wanna a scaffolding by using this plugin, try a simply command yarn create cesium, click create-cesium for more info.

Chinese tutorial: 中文教程

Install

npm i cesium vite-plugin-cesium vite -D
# yarn add cesium vite-plugin-cesium vite -D

Usage

add this plugin to vite.config.js

import { defineConfig } from 'vite';
import cesium from 'vite-plugin-cesium';
export default defineConfig({
  plugins: [cesium()]
});

add dev command to package.json

"scripts": {
  "dev": "vite",
  "build": "vite build"
}

run:

yarn dev

Options

rebuildCesium

  • Type : boolean
  • Default : false

Default copy min cesium file to dist. if true will rebuild cesium from source.

import { defineConfig } from 'vite';
import cesium from 'vite-plugin-cesium';
export default defineConfig({
  plugins: [
    cesium({
      rebuildCesium: true
    })
  ]
});

Demo

src/index.js

import { Viewer } from 'cesium';
import './css/main.css';

const viewer = new Viewer('cesiumContainer');

or if you like global Cesium object you can write as

import * as Cesium from 'cesium';
const viewer = new Cesium.Viewer('cesiumContainer');

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>cesium-vite</title>
    <script type="module" src="/src/index.js"></script>
  </head>

  <body>
    <div id="cesiumContainer"></div>
  </body>
</html>

src/css/main.css

html,
body,
#cesiumContainer {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

Add dev and build commands to package.json

"scripts": {
    "dev": "vite",
    "build": "vite build"
},

Run yarn dev

For full demo project please check ./demo folder.

License

MIT

More Repositories

1

learn-neovim-lua

Neovim 配置实战:从 0 到 1 打造自己的 IDE
Lua
1,075
star
2

vite-plugin-wasm-pack

🦀 Vite plugin for rust wasm-pack
TypeScript
183
star
3

InsisVim

🗃 An out-of-the-box Neovim IDE solution that setup development environment in an incredibly simple way.
Lua
88
star
4

create-cesium

🌏 Create blazing fast Cesium apps with no configuration.
JavaScript
45
star
5

as2ts

Convert ActionScript 3 to TypeScript on web
JavaScript
42
star
6

narrowing

🤖 TypeScript tiny narrowing helpers you better use.
TypeScript
29
star
7

Stage3D.js

Stage3d API on top of WebGL
TypeScript
21
star
8

coding-blog

程序员的私房极简博客系统
CSS
20
star
9

zimuzu

美剧资源
11
star
10

as3DataStructure

常见数据结构
ActionScript
10
star
11

ts-lerna-repo

lerna+ typescript + babel + rollup 项目结构
JavaScript
9
star
12

mini-shed

迷你屋 是一个开放,模块化,数据驱动,前端友好的小游戏框架 🎮(实验中)
TypeScript
8
star
13

ObjectSocket

flash与nodejs通过socket互相发送object
TypeScript
3
star
14

photon-vite

photon with vitejs demo
TypeScript
3
star
15

vite-wasm-game-of-life

An example of vite-plugin-wasm-pack
Rust
3
star
16

onePageHTML

《HTML and CSS Design and Build Websites》笔记
2
star
17

my-react-starter-2021

React 脚手架 Next.js + Chakra-ui + Recoil + axios-hooks
TypeScript
2
star
18

PDF2Mag

一键Pdf文档转Flash电子杂志
JavaScript
2
star
19

ogl-typescript-starter

ogl-typescript starter with code minifier and livereload dev server.
TypeScript
2
star
20

nshen.github.com

test new blog
HTML
2
star
21

tsup-tsm-demo

a typescript tsm package
TypeScript
1
star
22

next-palywright-action-demo

JavaScript
1
star
23

test-npm-crate

vite-plugin-wasm-pack test crate
Rust
1
star
24

dotfiles

Shell
1
star
25

lens-server

TypeScript
1
star
26

nshen

1
star
27

ts-project-starter

TypeScript Project Starter 2019
JavaScript
1
star
28

as3DesignPattern

学习设计模式用。。待整理
ActionScript
1
star
29

shed-ecs

Entity-Component-System for minigame
TypeScript
1
star
30

ts-jest-starter

JavaScript
1
star
31

cesium-rollup

cesium rollup starter
JavaScript
1
star