SnowMeshDesc
SnowMeshDescクラスは、雪のパーティクルエフェクトを表示するメッシュです。テクスチャベースのポイントスプライトを使用して、リアルな降雪効果を作成します。
以下のプロパティに加えて、基底クラスの共通プロパティ(position、rotation、scale、matrix、matrixWorld、geodetic、visible)が利用できます。詳細は MeshDesc を参照してください。
Common Properties
Section titled “Common Properties”position
Section titled “position”Type: { x: number, y: number, z: number } | Vector3
Description: 雪のパーティクルエフェクトの中心位置をECEF座標系で指定します。geodeticToVector3関数を使用して緯度経度から変換できます。
Example:
import { geodeticToVector3 } from "@navaramap/three";
const position = geodeticToVector3({ lat: 35.67564356091717, lng: 139.74511454748298, height: 10,});
{ position: position, snow: { ... }}visible
Section titled “visible”Type: boolean
Description: オブジェクトの表示/非表示を制御します。
Default: true
Example:
{ visible: false, snow: { ... }}Snow Properties
Section titled “Snow Properties”particleCount
Section titled “particleCount”Type: number
Description: 雪片のパーティクル数を指定します。
Default: 30000
Example:
{ snow: { particleCount: 3000, }}radius
Section titled “radius”Type: number
Description: 雪の分布半径を指定します。
Default: 10
Example:
{ snow: { radius: 15, }}areaWidth
Section titled “areaWidth”Type: number
Description: 降雪エリアの幅を指定します。
Default: 500
Example:
{ snow: { areaWidth: 500, }}areaHeight
Section titled “areaHeight”Type: number
Description: 降雪エリアの高さを指定します。
Default: 1000
Example:
{ snow: { areaHeight: 1000, }}Type: number
Description: 雪片の落下速度を指定します。
Default: 0.00005
Example:
{ snow: { speed: 0.001, }}movementStrength
Section titled “movementStrength”Type: { x: number, y: number, z: number }
Description: 雪片の風による移動の強度を各軸で指定します。
Default: { x: 50, y: 20, z: 50 }
Example:
{ snow: { movementStrength: { x: 0.5, y: 0, z: 0.5 }, }}movementSpeed
Section titled “movementSpeed”Type: { x: number, y: number, z: number }
Description: 雪片の風による移動の速度を各軸で指定します。
Default: { x: 0.0005, y: 0.0002, z: 0.0005 }
Example:
{ snow: { movementSpeed: { x: 0.001, y: 0, z: 0.001 }, }}Type: number
Description: 雪片のサイズを指定します。
Default: 3
Example:
{ snow: { size: 0.05, }}Type: number
Description: 雪片の色。
Default: 0xffffff
Example:
import { Color } from "@navaramap/three";
{ snow: { color: new Color().setStyle("#eeeeff").toHex(), }}opacity
Section titled “opacity”Type: number
Description: 雪片の不透明度を指定します。
Default: 1
Example:
{ snow: { opacity: 0.8, }}followCamera
Section titled “followCamera”Type: boolean
Description: メッシュがカメラに追従するかどうかを指定します。
Default: true
Example:
{ snow: { followCamera: true, }}maxHeight
Section titled “maxHeight”Type: number
Description: 最大高度を指定します。カメラの高度に比例して不透明度が減少します。
Default: 3000
Example:
{ snow: { maxHeight: 5000, }}Usage Examples
Section titled “Usage Examples”基本的な使い方
Section titled “基本的な使い方”import ThreeView from "@navaramap/three";import { SnowMeshDesc } from "@navaramap/three-default-descs";
const view = new ThreeView();view.registerMesh("snow", SnowMeshDesc);await view.init();
// SnowMeshDescを追加const snowDesc = view.addMesh<SnowMeshDesc>({ snow: { particleCount: 3000, areaWidth: 500, areaHeight: 1000, speed: 0.001, movementStrength: { x: 0.3, y: 0, z: 0.3 }, movementSpeed: { x: 0.0005, y: 0, z: 0.0005 }, size: 0.05, opacity: 0.8, followCamera: true, },});特定の位置に雪を配置
Section titled “特定の位置に雪を配置”import ThreeView, { Color, geodeticToVector3 } from "@navaramap/three";import { SnowMeshDesc } from "@navaramap/three-default-descs";
const view = new ThreeView({ animation: true });view.registerMesh("snow", SnowMeshDesc);await view.init();
// 東京の位置を計算const position = geodeticToVector3({ lat: 35.67564356091717, lng: 139.74511454748298, height: 10,});
// 位置を指定してSnowMeshDescを追加const snowDesc = view.addMesh<SnowMeshDesc>({ visible: true, position: position, snow: { particleCount: 3000, speed: 0.001, color: new Color().setHex(0xffffff).toHex(), opacity: 0.8, },});
// 表示/非表示を切り替えsnowDesc.visible = false;