本文へ移動

Wakusei Planets惑星

太陽・惑星・衛星を、線画、陰影つきの絵、表面の地図で描きます。実際の大きさ・傾き・自転つきで、任意の日時の衛星の位置も分かります。

「惑星」(わくせい) は、太陽のまわりを回る大きな星のことです。 名前について(英語)

目次

リファレンス · three.js での描き方

BodyLook型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

What a body looks like in three.js: the shader code of its surface, how it glows, its atmosphere and its painted map.

インポート

import type { BodyLook } from "@johnmorrisdotca/wakusei-planets/look";

定義

interface BodyLook {
    id: BodyId;
    surface: string;
    emissive?: boolean;
    atmosphere?: Atmosphere;
    limb?: number;
    relief?: number;
    wrap?: number;
    ambient?: number;
    painted?: PaintedMap;
    mapped?: boolean;
}

メンバー

名前型説明
idBodyId
surfacestring

GLSL that defines vec4 surface(vec3 p): p is the unit position on the body (x toward longitude 0 on the equator, y toward 90 degrees east, z the north pole); return the colour in rgb and the height in a.

emissive (省略可)boolean | undefined

A glowing body (the Sun): no shading from outside light.

atmosphere (省略可)Atmosphere | undefined
limb (省略可)number | undefined

How much the disc darkens toward the limb, 0 to 1. Default 0.

relief (省略可)number | undefined

How strongly the height shows as relief, 0 to 2. Default 0.6.

wrap (省略可)number | undefined

How far light wraps round the terminator: 0 is a hard edge (no air), 0.3 a soft one. Default 0.04, or 0.3 with an atmosphere.

ambient (省略可)number | undefined

How much of the night side shows (0 to 1). Default 0.04.

painted (省略可)PaintedMap | undefined
mapped (省略可)boolean | undefined

Draw the painted map in the realistic look too: for a body with no honest drawing from numbers (the Earth's continents).

例

import { registerLook, type BodyLook } from "@johnmorrisdotca/wakusei-planets/look";

const look: BodyLook = { id: "moon", surface: "vec4 surface(vec3 p) { return vec4(vec3(0.7), 0.0); }", ambient: 0.02 };
console.log(registerLook(look).id);
moon

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/wakusei-planets 0.24.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。