Class: Loader

mapray~ Loader


new Loader(scene, resource [, options])

ローダークラス

Parameters:
Name Type Argument Default Description
scene mapray.Scene

読み込み先のシーン

resource mapray.Resource
options object <optional>
{}
Properties
Name Type Argument Description
onLoad object <optional>

全ての読み込み完了時に呼ばれる

onEntity mapray.Loader.EntityCallback <optional>

エンティティが読み込まれるたびに呼ばれる

Source:

Members


<readonly> resource :string

シーンリソース

Type:
  • string
Source:

<readonly> scene :mapray.Scene

読み込み先のシーン

Type:
Source:

<readonly> status

ローダー読み込みの状態

Source:

Methods


cancel()

読み込みの取り消し

終了コールバック関数は isSuccess == false で呼び出される。

Source:

load()

読み込みを実行します。

Source:
Returns:
Type
Promise

Type Definitions


EntityCallback(loader, entity, prop)

Entity読み込みコールバック

読み込み処理の中でEntityが生成される際に呼ばれる。 一度の読み込み(load()呼び出し)において複数のエンティティが生成される場合は、エンティティが生成されるたびに呼ばれる。 この関数をLoaderに指定する場合は、callback処理の中でEntityをsceneへ追加する必要がある。 geojsonのように、要素ごとにプロパティを含められるような場合は、propにより値にアクセスする。

Parameters:
Name Type Description
loader mapray.Loader

Loader

entity mapray.Entity

読み込まれたEntity

prop object

エンティティ生成の元となるオブジェクト

Source:
Example
const loader = new mapray.SceneLoader( viewer.scene, resource, {
        onEntity: ( loader, entity, prop ) => {
            entity.setScale( [ 2, 2, 2 ] );
            loader.scene.addEntity( entity );
        }
} );
loader.load();

TransformCallback(url, type)

リソース要求変換関数

リソースのリクエスト時に URL などを変換する関数の型である。

Parameters:
Name Type Description
url string

変換前のリソース URL

type mapray.Resource.ResourceType

リソースの種類

Source:
Returns:

変換結果を表すオブジェクト

Type
mapray.Loader.TransformResult
Example
function( url, type ) {
    return {
        url:         url,
        credentials: mapray.CredentialMode.SAME_ORIGIN,
        headers: {
            'Header-Name': 'Header-Value'
        }
    };
}

TransformResult

リソース要求変換関数の変換結果

関数型 mapray.Loader.TransformCallback の戻り値のオブジェクト構造である。

Type:
  • object
Properties:
Name Type Argument Default Description
url string

変換後のリソース URL

credentials mapray.CredentialMode <optional>
SAME_ORIGIN

クレデンシャルモード

headers object <optional>
{}

リクエストに追加するヘッダーの辞書 (キーがヘッダー名、値がヘッダー値)

Source: