setIlluminationCondition は一度に一条件のみ有効です。再設定で上書きされます。import * as GIA from '@ntj/gaia';
const TOKYO = new GIA.value.LatLng(35.67289, 139.72958);
const SKY_COLOR = new GIA.value.Color(0.2, 0.2, 0.2, 1.0);
const FOG_COLOR = new GIA.value.Color(0.4, 0.4, 0.4, 1.0);
const FILTER_COLOR = new GIA.value.Color(0, 0, 0, 0.6);
// 1) 頂点生成callback(必須)
const surroundCallback = (): GIA.types.IlluminationVertexSpec[] => {
const specs: GIA.types.IlluminationVertexSpec[] = [];
for (let i = 0; i < 64; i++) {
specs.push({
position: {
x: 32 * Math.random() * Math.cos(i),
y: 32 * Math.random() * Math.sin(i),
z: 0.05 * i + 1.0,
},
});
}
return specs;
};
const options: GIA.types.IlluminationConditionInitOptions = {
source: {
surrounds: [{ callback: surroundCallback, method: 'vertex' }],
// 2) 画像素材(必須)
relays: [
{ image: '/asset/illumination/relay_001.png', method: 'instance' },
{ image: '/asset/illumination/relay_002.png', method: 'instance' },
],
signs: {
callbacks: new Map([
['tree', { callback: surroundCallback, method: 'vertex' }],
]),
images: new Map([
['ferris_wheel', { image: '/asset/illumination/sign_ferris_wheel.png', method: 'vertex' }],
]),
},
},
marker: {
creationCallback: (position, properties) => {
const info = new GIA.value.GLMarkerIconInfo({
icon: '/asset/illumination/pin.png',
size: new GIA.value.Size(30, 20),
});
const marker = new GIA.object.GLMarker({
position,
info,
label: {
content: properties.nameShorten,
offset: new GIA.value.Point(24, 4),
style: {
fontSize: '12px',
fontWeight: 'bold',
color: '#FFFFFF',
backgroundColor: '#88888888',
},
},
labelZoomRange: new GIA.value.ZoomRange(14, 24),
});
marker.addEventListener('click', () => {
alert(`${properties.name}\n${properties.periodDate}`);
});
return marker;
},
shiftZ: 60,
},
};
// 有効化
map.setSkyColor(SKY_COLOR);
map.setFogColor(FOG_COLOR);
map.setColorFilterColor(FILTER_COLOR);
map.setIlluminationCondition(new GIA.value.IlluminationCondition(options));
map.moveTo(TOKYO, map.getZoomLevel(), false);
map.setTilt(45);
map.setZoomLevel(13, true);
// 無効化
map.setIlluminationCondition();
map.setColorFilterColor(new GIA.value.Color(0, 0, 0, 0));
イルミネーション情報の表示条件を設定する — 詳細な使用例
IlluminationConditionInitOptionsのsourceでイルミネーション形状を定義し、marker.creationCallbackでスポットごとのGLMarkerを生成します。conditionにundefinedを渡すか引数省略でクリアできます。Illumination描画に必要な要素(必須)
method: 'vertex')surrounds/anchors/signs.callbacksのいずれかで() => IlluminationVertexSpec[]を返すrelaysのimagesigns.imagesのimagemarker.creationCallback内のピン画像source の構造
surroundsanchorsrelayssigns.callbackssigns.images