### Basic Vesium.js Usage in Vue
Source: https://github.com/vesiumjs/vesium/blob/main/packages/start.en.md
Demonstrates a basic setup for using Vesium.js within a Vue 3 application. It shows how to create a Cesium viewer instance, manage camera state using `useCameraState`, and log camera position changes.
```vue
```
--------------------------------
### Install Vesium.js with Package Managers
Source: https://github.com/vesiumjs/vesium/blob/main/packages/start.en.md
Install Vesium.js along with Cesium and VueUse using NPM, Yarn, or pnpm. These commands ensure all necessary dependencies are added to your project for Cesium integration.
```bash
# NPM
npm install cesium @vueuse/core vesium
# Yarn
yarn add cesium @vueuse/core vesium
# pnpm
pnpm add cesium @vueuse/core vesium
```
--------------------------------
### Installation
Source: https://context7.com/vesiumjs/vesium/llms.txt
Instructions for installing Vesium and its peer dependencies using NPM, Yarn, or pnpm.
```APIDOC
## Installation
Install Vesium and its peer dependencies using your preferred package manager.
```bash
# NPM
npm install cesium @vueuse/core vesium
# Yarn
yarn add cesium @vueuse/core vesium
# pnpm
pnpm add cesium @vueuse/core vesium
```
```
--------------------------------
### Load Vesium.js via CDN
Source: https://github.com/vesiumjs/vesium/blob/main/packages/start.en.md
Load Vesium.js and its dependencies (Cesium, VueUse) directly from a CDN. This method exposes all functionalities through the global `window.Vesium` object, suitable for quick integration without a build process.
```html
```
--------------------------------
### Load Single or Multiple Entities with useEntity (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useEntity/index.en.md
Demonstrates the usage of the useEntity hook for loading single or multiple Entity instances. It shows basic overloads and an example with optional configuration parameters like collection, isActive, and evaluating (loading status).
```typescript
// Overload 1: Load a single instance
const entity = useEntity(entity);
// Overload 2: Load an array of instances
const entities = useEntity([entity1, entity2]);
const isActive = ref(true);
const isLoading = ref(true);
// Options
const entity = useEntity(entity, {
collection,
isActive,
evaluating: isLoading
});
```
--------------------------------
### Vesium: Usage Examples for toPromiseValue (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/best.en.md
Demonstrates practical applications of the toPromiseValue function with different input types: a direct value, a Vue ref, and an async getter. It also shows integration with VueUse's computedAsync for managing asynchronous computed properties.
```typescript
// Usage examples
toPromiseValue(1);
toPromiseValue(ref(1));
toPromiseValue(async () => await fetchData()); // -> Promise
const value = computedAsync(() => toPromiseValue(asyncData));
```
--------------------------------
### Avoid Hooks in Global State Management (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/best.en.md
Explains why Vesium hooks should not be used directly within global state management solutions like Vuex or Pinia. It provides examples of the non-recommended approach and the recommended separation of concerns, handling viewer-related logic within components.
```typescript
// ❌ Not recommended: using Hooks in store
// /src/store/main.ts
defineStore('main', () => {
const entity = shallowRef(new Cesium.Entity({}));
useEntity(entity); // Error: cannot access viewer instance
});
```
```typescript
// ✅ Recommended: separation of concerns
// /src/store/main.ts
defineStore('main', () => {
const entity = shallowRef(new Cesium.Entity({}));
return { entity };
});
// /src/components/entity.vue
const mainStore = useMainStore();
const { viewer } = useViewer();
useEntity(() => mainStore.entity); // Handle viewer-related logic in component
```
--------------------------------
### Use useScenePick Hook (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useScenePick/index.en.md
Demonstrates how to use the useScenePick hook in TypeScript. It initializes a window position and then calls the hook to get the pick functionality. The hook returns a function that can be called with the current window position to perform the pick operation.
```typescript
import { shallowRef } from "vue";
import * as Cesium from "cesium";
import { useScenePick } from "@vesiumjs/vesium";
const windowPosition = shallowRef(new Cesium.Cartesian2());
const pick = useScenePick(windowPosition, { /** options */ });
// To perform a pick operation:
// const pickedObject = await pick();
```
--------------------------------
### Access Reactive Instances in Lifecycle Hooks (Vue)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/best.en.md
Illustrates the correct way to access and manipulate reactive Cesium instances within Vue components. It highlights the importance of using lifecycle hooks like `watchEffect` to ensure instances are initialized before interaction, contrasting it with direct access in `setup`.
```vue
// ❌ Not recommended: accessing directly in setup
```
```vue
// ✅ Recommended: accessing in lifecycle hooks
```
--------------------------------
### Use Shallow Reactivity for Cesium Instances (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/best.en.md
Demonstrates the recommended use of `shallowRef` for Cesium instances to avoid performance issues and interference with Cesium's internal mechanisms. It contrasts this with the non-recommended deep reactivity approach.
```typescript
// ❌ Not recommended: using deep reactivity
const entity = ref(new Cesium.Entity());
useEntity(entity);
watch(position, (position) => {
entity.position = position; // Error: not accessing with .value
});
```
```typescript
// ✅ Recommended: using shallow reactivity
const entity = shallowRef(new Cesium.Entity());
useEntity(entity);
watch(position, (position) => {
entity.value.position = position; // Correct: accessing with .value
triggerRef(entity); // Manually trigger update
});
```
--------------------------------
### Basic useElementOverlay Usage (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useElementOverlay/index.en.md
Demonstrates the fundamental usage of the useElementOverlay composable. It requires a target HTML element and a Cesium position. Optional configuration includes alignment, offset, and reference window settings.
```typescript
const { x, y, elementOverlay } = useElementOverlay(
targetElement,
position,
{
horizontal: 'center',
vertical: 'bottom',
offset: { x: 0, y: 0 },
referenceWindow: false,
}
);
```
--------------------------------
### Initialize or Reuse Viewer Instance (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/createViewer/index.en.md
Demonstrates how to initialize a new VesiumJS Viewer instance or reuse an existing one using createViewer. The first overload creates a new instance managed by the component's lifecycle, while the second injects a pre-existing instance. The useViewer hook can then access the created or injected instance.
```typescript
// overLoad1: Creates a new instance, which is automatically destroyed when the component unmounts
const viewer = createViewer(elRef, {
// ...options
});
// overLoad2: Injects an existing instance, which is not automatically destroyed when the component unmounts
const viewer = createViewer(window.viewer);
// After creating an instance, the current component and its descendant components can access the instance using useViewer
const viewer = useViewer();
```
--------------------------------
### Manage Cesium Collection Side Effects with useCollectionScope (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useCollectionScope/index.en.md
This example demonstrates how to use the `useCollectionScope` hook to add and remove entities from a Cesium viewer's collection. It automatically handles the removal of entities when the component unmounts, preventing memory leaks. The hook requires `addEffect` and `removeEffect` functions to interact with the Cesium collection.
```typescript
import { useCollectionScope } from 'vesium';
const { add, remove, scope } = useCollectionScope({
addEffect: instance => viewer.entities.add(instance),
removeEffect: instance => viewer.entities.remove(instance)
});
const entity = add({ id: 'test' });
// When the component is unmounted, the entity is automatically removed from viewer.entities
```
--------------------------------
### Configure Primitive Loading with Options using usePrimitive (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/usePrimitive/index.en.md
Shows how to configure the usePrimitive hook with additional options for advanced control. This overload allows specifying a primitive collection, activation status, and a loading status reference, enabling fine-grained management of primitive behavior and state.
```typescript
import { usePrimitive } from 'vesiumjs';
import { ref } from 'vue';
// Assume 'collection' is a Cesium PrimitiveCollection
const collection = new Cesium.PrimitiveCollection();
const isActive = ref(true);
const isLoading = ref(true);
const primitive = usePrimitive(primitiveToLoad, {
collection: collection,
isActive: isActive,
evaluating: isLoading // Loading status reference
});
```
--------------------------------
### createViewer
Source: https://context7.com/vesiumjs/vesium/llms.txt
Initializes a Cesium Viewer instance or reuses an existing one. The viewer is automatically destroyed when the component unmounts.
```APIDOC
## createViewer
Initializes a Cesium Viewer instance or reuses an existing instance. The created viewer can be accessed by `useViewer` in the current component and its descendant components. The viewer is automatically destroyed when the component unmounts.
### Method
```
createViewer(container: HTMLElement | ShallowRef, options?: Viewer.ViewerOptions): Ref
createViewer(viewer: Viewer): Ref
```
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
**container** (HTMLElement | ShallowRef) - Required - The HTML element or shallow ref to contain the Cesium Viewer.
**options** (Viewer.ViewerOptions) - Optional - Configuration options for the Cesium Viewer.
**viewer** (Viewer) - Required - An existing Cesium Viewer instance to be managed.
### Request Example
```vue
```
### Response
#### Success Response (200)
- **viewer** (Ref) - A Vue ref containing the Cesium Viewer instance.
#### Response Example
```json
{
"viewer": "Cesium.Viewer instance"
}
```
```
--------------------------------
### Create Cesium Viewer Instance (Vue)
Source: https://context7.com/vesiumjs/vesium/llms.txt
Initializes a Cesium Viewer instance within a Vue component. It can create a new viewer or reuse an existing one, automatically managing its lifecycle. The viewer is accessible via `useViewer` in descendant components.
```vue
```
--------------------------------
### Understanding MaybeRefOrGetter and toValue (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/best.en.md
Demonstrates the `MaybeRefOrGetter` type and the `toValue` utility function commonly used in Vue and VueUse. It shows how `toValue` correctly extracts the value from refs, getters, or plain values to ensure compatibility with Vue's reactivity system.
```typescript
type MaybeRefOrGetter = Ref | (() => T) | T;
function toValue(value: MaybeRefOrGetter): T;
toValue(1); // -> 1
toValue(ref(1)); // -> 1
toValue(() => 1); // -> 1
```
--------------------------------
### useCameraState
Source: https://context7.com/vesiumjs/vesium/llms.txt
Provides reactive access to the Cesium Camera instance state, including position, direction, and view rectangle.
```APIDOC
## useCameraState
Provides reactive access to the Cesium Camera instance state. Returns computed properties for camera position, direction, heading, pitch, roll, and view rectangle that automatically update when the camera moves.
### Method
```
useCameraState(options?: { event?: 'changed' | 'moveStart' | 'moveEnd'; delay?: number }): {
camera: Ref;
position: Ref;
positionCartographic: Ref;
heading: Ref;
pitch: Ref;
roll: Ref;
viewRectangle: Ref;
level: Ref;
}
```
### Parameters
#### Query Parameters
- **options** (object) - Optional - Configuration options for camera state tracking.
- **event** (string) - Optional - The camera event to listen for. Defaults to 'changed'. Possible values: 'changed', 'moveStart', 'moveEnd'.
- **delay** (number) - Optional - Throttle delay in milliseconds for updates. Defaults to 0.
### Request Example
```vue
```
### Response
#### Success Response (200)
- **camera** (Ref) - A Vue ref containing the Cesium Camera instance.
- **position** (Ref) - A Vue ref containing the Cartesian3 position of the camera.
- **positionCartographic** (Ref) - A Vue ref containing the Cartographic position (longitude, latitude, height in radians) of the camera.
- **heading** (Ref) - A Vue ref containing the camera's heading in radians.
- **pitch** (Ref) - A Vue ref containing the camera's pitch in radians.
- **roll** (Ref) - A Vue ref containing the camera's roll in radians.
- **viewRectangle** (Ref) - A Vue ref containing the visible rectangle on the ellipsoid.
- **level** (Ref) - A Vue ref containing the computed zoom level.
#### Response Example
```json
{
"camera": "Cesium.Camera instance",
"position": {
"x": 1234567.89,
"y": 2345678.90,
"z": 3456789.01
},
"positionCartographic": {
"longitude": 1.2345,
"latitude": 0.6789,
"height": 10000.0
},
"heading": 0.5,
"pitch": -0.2,
"roll": 0.0,
"viewRectangle": {
"west": -1.0,
"south": -0.5,
"east": 1.0,
"north": 0.5
},
"level": 15
}
```
```
--------------------------------
### Use Viewer Instance in Same Component (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useViewer/index.en.md
Demonstrates how to create a Viewer instance and then retrieve it within the same component using the useViewer hook. This ensures the component has access to the viewer's functionalities.
```typescript
createViewer(/** options */);
// Must be called after `createViewer`
const viewer = useViewer();
```
--------------------------------
### Use Cesium Event Listener with Throttling (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useCesiumEventListener/index.en.md
Demonstrates how to use `useCesiumEventListener` with throttling for Cesium's `postRender` event. It shows how to integrate with `@vesium/shared`'s `throttle` and `@vueuse/core`'s `refThrottled` to manage frequent event triggers.
```typescript
import { throttle } from '@vesium/shared';
import { refThrottled } from '@vueuse/core';
import { useCesiumEventListener } from 'vesium';
const listener = throttle(() => {
// TODO
}, 100);
useCesiumEventListener(() => viewer.value?.scene.postRender, listener);
const current = refThrottled(ref(new Date().getTime()), 100);
useCesiumEventListener(() => viewer.value?.scene.postRender, () => {
current.value = new Date().getTime();
});
```
--------------------------------
### useViewer
Source: https://context7.com/vesiumjs/vesium/llms.txt
Retrieves the Viewer instance injected by `createViewer` in the current component or its ancestor components.
```APIDOC
## useViewer
Retrieves the Viewer instance injected by `createViewer` in the current component or its ancestor components. Must be called after `createViewer` when used in the same component.
### Method
```
useViewer(): Ref
```
### Parameters
None
### Request Example
```vue
```
```vue
```
### Response
#### Success Response (200)
- **viewer** (Ref) - A Vue ref containing the Cesium Viewer instance.
#### Response Example
```json
{
"viewer": "Cesium.Viewer instance"
}
```
```
--------------------------------
### Configure ImageryLayer Loading with Options
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useImageryLayer/index.en.md
Loads an ImageryLayer instance with advanced configuration options using the useImageryLayer composable. This includes specifying the imagery layer collection, activation status, loading indicator, and destruction behavior.
```typescript
const dataSource = useImageryLayer(layer, {
collection,
isActive,
evaluating: isLoading,
destroyOnRemove: false,
});
```
--------------------------------
### Load Basic ImageryLayer Instance with useImageryLayer
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useImageryLayer/index.en.md
Loads a basic ImageryLayer instance using the useImageryLayer composable. This function is suitable for straightforward layer loading scenarios where the layer data is readily available.
```typescript
const images = useImageryLayer(layer);
```
--------------------------------
### Load Single Primitive Instance with usePrimitive (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/usePrimitive/index.en.md
Demonstrates how to use the usePrimitive hook to load a single Cesium Primitive instance. This overload accepts either a pre-defined primitive object or a new instance of a Cesium Primitive class. It's useful for managing individual 3D tilesets or other primitive elements.
```typescript
import { usePrimitive } from 'vesiumjs';
import * as Cesium from 'cesium';
// Load a single instance using a pre-defined primitive
const primitive = usePrimitive(predefinedPrimitive);
// Load a single instance by creating a new Cesium3DTileset
const primitive = usePrimitive(new Cesium.Cesium3DTileset());
```
--------------------------------
### Use Viewer Instance in Descendant Component (Vue)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useViewer/index.en.md
Shows how to create a Viewer instance in a parent Vue component and then access it in a child component using the useViewer hook. This pattern is useful for managing viewer state across a component tree.
```vue
// parent.vue
```
```vue
// child.vue
```
--------------------------------
### Load 3D Tilesets, Models, and Geometries with usePrimitive
Source: https://context7.com/vesiumjs/vesium/llms.txt
The `usePrimitive` hook in VesiumJS allows for reactive loading of various 3D primitives like Cesium 3DTilesets, glTF models, and custom geometries. It supports loading individual primitives, collections, or multiple primitives simultaneously, managing their lifecycle within the Cesium scene.
```vue
```
--------------------------------
### Load Imagery Layers Reactively with useImageryLayer (Vue.js)
Source: https://context7.com/vesiumjs/vesium/llms.txt
The `useImageryLayer` hook from VesiumJS provides reactive loading of Cesium imagery layers to the globe. It supports various imagery providers and manages layers automatically, including cleanup. Dependencies include Vue's reactivity system and CesiumJS.
```vue
```
--------------------------------
### Scale Bar Demo Component (Vue)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useScaleBar/index.en.md
A Vue.js component demonstrating the usage of the useScaleBar hook. It initializes a scale bar and provides controls to update its properties.
```html
```
--------------------------------
### Load Multiple Primitive Instances with usePrimitive (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/usePrimitive/index.en.md
Illustrates loading an array of Cesium Primitive instances using the usePrimitive hook. This overload is suitable when you need to manage multiple primitives reactively, such as several 3D tilesets or different types of primitives simultaneously.
```typescript
import { usePrimitive } from 'vesiumjs';
// Assume primitive1 and primitive2 are defined Cesium Primitive instances
const primitives = usePrimitive([primitive1, primitive2]);
```
--------------------------------
### Access Reactive Cesium Camera State (Vue)
Source: https://context7.com/vesiumjs/vesium/llms.txt
Provides reactive access to the Cesium Camera instance and its state, including position, direction, and view rectangle. It allows watching for camera changes with configurable event types and throttling.
```vue
```
--------------------------------
### Reactive Scene Picking with useScenePick (Vue)
Source: https://context7.com/vesiumjs/vesium/llms.txt
The `useScenePick` hook provides reactive results for Cesium's Scene.pick function, allowing for efficient picking of objects at screen coordinates. It supports throttling and customizable picking rectangle dimensions. Dependencies include `vesium` and `cesium`.
```vue
```
--------------------------------
### Camera State Type Definitions (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useCameraState/index.en.md
Defines the TypeScript types for the Camera instance state, enabling type-safe access and manipulation. This is crucial for understanding the structure of the camera's reactive state.
```typescript
import {
CameraState,
CameraStateUpdateOptions
} from "./index.d";
export declare function useCameraState(): {
state: CameraState;
update: (options: CameraStateUpdateOptions) => void;
};
```
--------------------------------
### Subscribe to Cesium Events with useCesiumEventListener
Source: https://context7.com/vesiumjs/vesium/llms.txt
The `useCesiumEventListener` hook provides a convenient way to subscribe to Cesium Event instances, ensuring automatic cleanup of listeners. It's recommended to use this with throttling for high-frequency events like scene rendering. It accepts an event source (or an array of sources) and a callback function, with an optional configuration object for conditional activation. Dependencies include `vesium`, `@vesium/shared`, and `@vueuse/core`.
```vue
```
--------------------------------
### Load Array of ImageryLayers with useImageryLayer
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useImageryLayer/index.en.md
Loads multiple ImageryLayer instances from an array using the useImageryLayer composable. This allows for efficient loading and management of several layers simultaneously.
```typescript
const dataSources = useImageryLayer([layer1, layer2]);
```
--------------------------------
### Load Asynchronous ImageryLayer Instance with useImageryLayer
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useImageryLayer/index.en.md
Loads an ImageryLayer instance asynchronously using the useImageryLayer composable. This is useful when the layer data needs to be fetched before it can be loaded, ensuring the layer is ready when needed.
```typescript
const dataSource = useImageryLayer(async () => await getLayer());
```
--------------------------------
### Normalize to Promise Instance with toPromiseValue (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/toPromiseValue/index.en.md
Demonstrates how to use toPromiseValue to normalize Promises, async functions, and regular Refs into Promise instances. This function is particularly useful when working with asynchronous data sources and integrating with tools like computedAsync.
```typescript
import { computedAsync, ref } from '@vueuse/core';
import { toPromiseValue } from 'vesium';
// Handling Promise instances
const promiseRef = ref(Promise.resolve('Hello World'));
const data = computedAsync(() => toPromiseValue(promiseRef));
// data.value -> 'Hello World'
// Handling async functions
async function asyncFn() {
return 'Hello World';
}
const data = computedAsync(() => toPromiseValue(asyncFn));
// data.value -> 'Hello World'
// Handling regular Refs
const normalRef = ref('Hello World');
const data = computedAsync(() => toPromiseValue(normalRef));
// data.value -> 'Hello World'
```
--------------------------------
### Use Scene Drill Pick with TypeScript
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useSceneDrillPick/index.en.md
Demonstrates how to use the useSceneDrillPick hook with a CesiumJS Cartesian2 window position. The hook returns computed pick results based on the provided position and optional configuration.
```typescript
const windowPosition = shallowRef(new Cesium.Cartesian2());
const picks = useSceneDrillPick(windowPosition, { /** options */ });
```
--------------------------------
### Configure useDataSource with Options (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useDataSource/index.en.md
Explains how to configure the useDataSource hook with various options for advanced control. Options include specifying the collection, activation status, loading state, and destruction behavior.
```typescript
const isLoading = ref(true);
// Use options
const dataSource = useDataSource(someDataSource, {
collection: someCollection, // DataSource collection
isActive: true, // Whether to activate
evaluating: isLoading, // Loading status reference
destroyOnRemove: true, // Whether to destroy when the DataSource is removed
});
```
--------------------------------
### Load Basic Cesium DataSource with useDataSource (TypeScript)
Source: https://github.com/vesiumjs/vesium/blob/main/packages/core/useDataSource/index.en.md
Demonstrates the basic usage of the useDataSource hook to load a single Cesium DataSource instance. It takes a DataSource object as input and returns a reactive DataSource.
```typescript
// Load a basic instance
const dataSource = useDataSource(someDataSource);
```
--------------------------------
### Overlay HTML Elements on Cesium Map with useElementOverlay
Source: https://context7.com/vesiumjs/vesium/llms.txt
The `useElementOverlay` hook allows you to overlay HTML elements on the Cesium map at specific geographic positions. It automatically updates the element's position as the camera moves. You provide a reference to the HTML element and its desired geographic position (in various formats like [lon, lat, height], or Cartesian3). The hook returns reactive `x`, `y` coordinates and a `style` object for positioning. Dependencies include `vesium` and `cesium`.
```vue
Beijing
Position: {{ position[0] }}, {{ position[1] }}
Screen X: {{ x }}, Y: {{ y }}
```
--------------------------------
### Apply Post-Processing Effects with usePostProcessStage
Source: https://context7.com/vesiumjs/vesium/llms.txt
The `usePostProcessStage` hook enables the reactive addition of post-processing effects, such as shaders, to the Cesium scene. It handles the lifecycle management and automatic cleanup of these stages, allowing for effects like bloom or custom shader manipulations.
```vue
```
--------------------------------
### Retrieve Cesium Viewer Instance (Vue)
Source: https://context7.com/vesiumjs/vesium/llms.txt
Retrieves a Cesium Viewer instance that was previously injected by `createViewer` in an ancestor component. This hook must be called after `createViewer` if used within the same component.
```vue
```
```vue
```
--------------------------------
### Load Entities Reactively with useEntity (Vue.js)
Source: https://context7.com/vesiumjs/vesium/llms.txt
The `useEntity` hook from VesiumJS allows for reactive loading of Cesium Entity objects within a Vue.js application. It automatically handles updates and cleanup when the component unmounts or data changes. Dependencies include Vue's reactivity system and CesiumJS.
```vue
```
--------------------------------
### Load Data Sources Reactively with useDataSource (Vue.js)
Source: https://context7.com/vesiumjs/vesium/llms.txt
The `useDataSource` hook from VesiumJS enables reactive loading of Cesium DataSource objects, supporting formats like GeoJSON, KML, and CZML. It handles both synchronous and asynchronous loading, with automatic cleanup. Dependencies include Vue's reactivity system and CesiumJS.
```vue
```