Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript #216

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
aade6fc
Merge pull request #211 from sony/0.8.8-release
daisuke201 Jun 3, 2021
961997b
typescript: add typescript libs
masa-sony Jun 5, 2021
d1fdb91
typescript: setup typescript for mapray
masa-sony Jun 5, 2021
38320b7
typescript: setup typescript for maprayui
masa-sony Jun 5, 2021
a3f6920
typescript: add typedoc and change entry point
masa-sony Jun 6, 2021
1d92fbe
typescript: add additional typescript lib
masa-sony Jul 14, 2021
878acea
typescript(rename): GeoMath, GeoPoint, Orientation, GeoRegion
masa-sony Jun 16, 2021
499ee38
typescript: GeoMath, GeoPoint, Orientation, GeoRegion
masa-sony Jun 16, 2021
c63c26c
typescript(rename): util/Dom
masa-sony Jun 16, 2021
aecc92b
typescript: util/Dom
masa-sony Jun 16, 2021
7897eef
typescript(rename): util/Color
masa-sony Jun 18, 2021
cfca1ad
typescript: util/Color
masa-sony Jun 18, 2021
c2aab05
typescript(rename): Viewer, RenderCallback, NullRenderCallback
masa-sony Jun 16, 2021
2f7abec
typescript: Viewer, RenderCallback, NullRenderCallback
masa-sony Jun 16, 2021
ce8fcaf
typescript(rename): Scene, RenderStage
masa-sony Jul 14, 2021
3c7290f
typescript: Scene, RenderStage, (Viewer, Materials)
masa-sony Jul 16, 2021
17fe07a
typescript(rename): Camera
masa-sony Jul 14, 2021
00132db
typescript: Camera
masa-sony Jul 14, 2021
a4912f7
typescript(rename): animation classes
masa-sony Jun 16, 2021
61bcc3e
typescript: animation classes
masa-sony Jun 16, 2021
036c5cc
typescript(rename): Entity
masa-sony Jun 16, 2021
f30a929
typescript: Entity
masa-sony Jun 16, 2021
fc0c2e6
typescript(rename): ModelEntity
masa-sony Jun 16, 2021
58e7066
typescript: ModelEntity
masa-sony Jun 16, 2021
bd92703
typescript(rename): AbstractPointEntity, PinEntity, TextEntity, Image…
masa-sony Jun 16, 2021
1268165
typescript: AbstractPointEntity, PinEntity, TextEntity, ImageIconEntity
masa-sony Jun 16, 2021
e1f720a
typescript(rename): Loader, SceneLoader, Resource, CredentialMode
masa-sony Jun 16, 2021
482cd3e
typescript: Loader, SceneLoader, Resource, CredentialMode
masa-sony Jun 16, 2021
f408540
typescript(rename): HTTP
masa-sony Jun 16, 2021
cf9faa6
typescript: HTTP
masa-sony Jun 16, 2021
f436869
typescript(rename): MaprayApi, MaprayApiModel, MaprayApiResource
masa-sony Jun 16, 2021
f165a96
typescript: MaprayApi, MaprayApiModel, MaprayApiResource
masa-sony Jun 16, 2021
2376bb1
typescript: GeoJSON
masa-sony Jun 16, 2021
507345f
typescript(rename): StandardUIViewer
masa-sony Jun 17, 2021
f5808c5
typescript: StandardUIViewer
masa-sony Jun 18, 2021
c44a052
typescript(rename): GeoJSONLoader
masa-sony Jun 18, 2021
7f255f0
typescript: GeoJSONLoader
masa-sony Jun 20, 2021
56ba2e7
typescript(rename): PolygonEntity, ConvexPolygon, AreaUtil
masa-sony Jun 22, 2021
b60fba3
typescript: PolygonEntity
masa-sony Jul 2, 2021
77689ca
typescript(rename): AbstractLineEntity, MarkerLineEntity, PathEntity
masa-sony Jul 2, 2021
9582894
typescript: AbstractLineEntity, MarkerLineEntity, PathEntity
masa-sony Jul 5, 2021
7a5064b
typescript: minor fixes
masa-sony Jul 13, 2021
2f172ac
typescript: moved browser wrapper function of native function into ut…
masa-sony Jul 13, 2021
14d7cac
typescript(rename): ImageProvider, EmptyImageProvider, StandardImageP…
masa-sony Jul 14, 2021
78854d6
typescript: ImageProvider, EmptyImageProvider, StandardImageProvider
masa-sony Jul 14, 2021
93fc649
typescript: apps: remove rambler
masa-sony Jul 13, 2021
82db60a
typescript: apps: merge fall and turning
masa-sony Jul 13, 2021
6fe7c00
typescript: apps: modified next_esm and next_umd
masa-sony Jul 13, 2021
700de24
typescript: apps: modified uievents
masa-sony Jul 14, 2021
e50420c
typescript: debug: update picking
masa-sony Jul 13, 2021
763e2d6
typescript: debug: update point-cloud
masa-sony Jul 13, 2021
19d1187
typescript: debug: update render-phase
masa-sony Jul 13, 2021
51ab727
bug fix of ModelEntity
masa-sony Jul 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
build/
dist/
doc/jsdoc/
doc/typedoc/
doc/typedoc-devel/
node_modules/

*/**/yarn.lock
Expand Down
16 changes: 8 additions & 8 deletions apps/fall/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# maprayJS Fall
# mapray-js Fall
This is a simple demo application with beautiful Mt Fuji on [Mapray](https://mapray.com) website.

## Preparing your Development Environment
Expand All @@ -14,26 +14,26 @@ brew install yarn
```

## Usage
**To set access token:**

### Set access token

To see the terrian data, you need a [Mapray access token](/doc/developer-guide/GettingStarted/index.md). You can either set an environment variable:

```bash
export MAPRAY_ACCESS_TOKEN=<mapray_access_token>
```

Or set accsess token to `<your access token here>` directly in `Fall.js`.
Or set accsess token to `<your access token here>` directly in `Fall.js` and `Turn.js`.


**To install dependencies:**
### Install dependencies

```bash
npm install
# or
yarn
```

**Commands:**
* `npm start` is the development target, to serves the app and hot reload.
* `npm run build` is the production target, to create the final bundle and write to disk.
* `npm run start-local` is the target for developing mapray and ui packages, to include mapray packages from local modules to write to disk.
### Commands
- `npm start` is the development target, to serves the app and hot reload.
- `npm run build-prod` is the production target, to create the final bundle and write to disk.
34 changes: 23 additions & 11 deletions apps/fall/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,40 @@
</noscript>
<style>
#mapray-container {
width: 98%;
height: 95%;
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
padding: 0;
border: solid 2px blue;
background: rgb(236, 236, 236);
position: relative;
box-shadow: inset 0 0px 50px 20px #aaa;
}
html {
height: 100%;
}
body {
padding: 0;
html, body {
margin: 0;
overflow: hidden;
padding: 0;
height: 100%;
}
.toolbar {
position: fixed;
height: 40px;
z-index: 10;
}
.toolbar input {
display: inline-block;
height: 30px;
padding: 0 15px;
margin: 5px 5px 5px 0;
}
.toolbar input:first-child {
margin: 5px;
}
</style>
</head>
<body>
<div>
<input type="button" value="start" onclick="window.startApp('mapray-container');"/>
<div class="toolbar">
<input type="button" value="Fall" onclick="window.startApp('mapray-container', 'fall');"/><!--
--><input type="button" value="Turn" onclick="window.startApp('mapray-container', 'turn');"/>
</div>
<div id="mapray-container">
</div>
Expand Down
10 changes: 4 additions & 6 deletions apps/fall/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
"version": "0.0.0",
"license": "MIT",
"scripts": {
"start": "run-p start-server build-watch",
"start-local": "run-p start-server local-watch",
"build": "rollup -c --environment BUILD:production",
"start": "run-p server build-watch",
"build": "rollup -c",
"build-prod": "rollup -c --environment BUILD:production",
"build-watch": "rollup -c -w",
"local": "rollup -c --environment local,BUILD:production",
"local-watch": "rollup -c -w --environment local",
"start-server": "st --no-cache -H 0.0.0.0 --port 7776 --index index.html ."
"server": "st --no-cache -H 0.0.0.0 --port 7776 --index index.html --dir ."
},
"devDependencies": {
"@babel/core": "^7.8.6",
Expand Down
130 changes: 44 additions & 86 deletions apps/fall/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,98 +1,56 @@
import path from 'path'
import { terser } from 'rollup-plugin-terser'
import babel from 'rollup-plugin-babel'
import { string } from 'rollup-plugin-string'
import replace from 'rollup-plugin-replace'
import postcss from 'rollup-plugin-postcss'
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import strip from '@rollup/plugin-strip';
import { addLocalSettings } from '../rollup.config.local.js'
import path from 'path';
import { terser } from 'rollup-plugin-terser';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import postcss from 'rollup-plugin-postcss';
import resolve from 'rollup-plugin-node-resolve';

var outdir = "dist/"

let accessToken = '"<your access token here>"'
if (process.env.MAPRAY_ACCESS_TOKEN) {
accessToken = JSON.stringify(process.env.MAPRAY_ACCESS_TOKEN)
}

const getPluginsConfig = (prod) => {
const params = [
postcss(),
replace({
'"<your access token here>"': accessToken,
delimiters: ['', '']
}),
commonjs(),
resolve(),
(process.env.local && prod ?
strip({
include: [
'src/**/*.js',
'../../**/*.js'
],
debugger: false,
functions: [ 'console.assert' ],
labels: [ 'ASSERT' ],
sourceMap: true,
})
: null),
(process.env.local ?
string({
include: [
'../../**/*.vert',
'../../**/*.frag',
]
})
: null),
babel({
exclude: 'node_modules/**'
})
]
const outdir = "dist/";

if (prod) {
params.push(
terser({
compress: {
unused: false,
collapse_vars: false,
},
output: {
comments: false,
},
})
)
}

return params;
}

const config = (build) => {
export default () => {

const isProd = process.env.BUILD === 'production';
const maprayAccessToken = process.env.MAPRAY_ACCESS_TOKEN;

const bundle = {
input: 'src/index.js',
output: {
file: outdir+'bundle.js',
format: 'iife',
output: {
file: outdir + 'bundle.js',
format: 'iife',
indent: false,
sourcemap: true
}
sourcemap: !isProd,
},
plugins: [
postcss(),
(maprayAccessToken ?
replace({
'"<your access token here>"': JSON.stringify( maprayAccessToken ),
delimiters: ['', ''],
}):
null
),
resolve(),
babel({
exclude: 'node_modules/**',
}),
(isProd ?
terser({
compress: {
unused: false,
collapse_vars: false,
},
output: {
comments: false,
},
}):
null
)
]
}
bundle.plugins = getPluginsConfig(build === 'production')

return bundle
}

// get the setting when developing in local environment
const loadLocalSetting = (env) => {
const appDir = path.join(__dirname, '../')
let bundle = config(env.BUILD)
bundle = addLocalSettings(env, appDir, bundle)
return bundle
}

export default () => {
if (process.env.local) {
return loadLocalSetting(process.env)
}
return config(process.env.BUILD);
return bundle;
}
74 changes: 65 additions & 9 deletions apps/fall/src/Fall.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
import mapray from "@mapray/mapray-js";
import FallRenderCallback from "./FallRenderCallback";

const GeoMath = mapray.GeoMath;


const accessToken = "<your access token here>";



/**
* @summary 下降カメラ
*/
class Fall {
class Fall extends mapray.RenderCallback {

/**
* @param {string|Element} container コンテナ (ID または要素)
*/
constructor( container )
{
this._image_provider = new mapray.StandardImageProvider( "https://cyberjapandata.gsi.go.jp/xyz/seamlessphoto/", ".jpg", 256, 0, 18 );
this._render_callback = new FallRenderCallback( this );

this._viewer = new mapray.Viewer( container, { image_provider: this._image_provider,
dem_provider: new mapray.CloudDemProvider(accessToken),
render_callback: this._render_callback } );
super();
this._viewer = new mapray.Viewer( container, {
render_callback: this,
image_provider: this.createImageProvider(),
dem_provider: new mapray.CloudDemProvider(accessToken),
});
this._viewer.attribution_controller.addAttribution({
display: "国土地理院",
link: "http://maps.gsi.go.jp/development/ichiran.html"
});
});

const home_pos = { longitude: 138.727778, latitude: 35.360556, height: 0 };
this._home_to_gocs = GeoMath.iscs_to_gocs_matrix( home_pos, GeoMath.createMatrix() );

this._cam_position = GeoMath.createVector3();
this._cam_end_pos = GeoMath.createVector3( [-150, 500, 3900] );
this._cam_eye_target = GeoMath.createVector3( [1500, -1000, 3200.0] );
this._cam_up = GeoMath.createVector3( [0, 0, 1] );
this._cam_speed = Math.log( 1 - 0.1 );
}


/**
* アプリを停止してから削除する。
*/
Expand All @@ -34,6 +47,49 @@ class Fall {
this._viewer.destroy();
}


/**
* @override
*/
onStart()
{
GeoMath.copyVector3( [0, 100000, 50000], this._cam_position );
}


/**
* @override
*/
onUpdateFrame( delta_time )
{
const camera = this.viewer.camera;

// _cam_position を更新
const a = 1 - Math.exp( this._cam_speed * delta_time );
const e = this._cam_end_pos;
const p = this._cam_position;
p[0] = a*(e[0] - p[0]) + p[0];
p[1] = a*(e[1] - p[1]) + p[1];
p[2] = a*(e[2] - p[2]) + p[2];

// _view_to_gocs を更新
const view_to_home = GeoMath.createMatrix();
GeoMath.lookat_matrix( p, this._cam_eye_target, this._cam_up, view_to_home );

const view_to_gocs = camera.view_to_gocs;
GeoMath.mul_AA( this._home_to_gocs, view_to_home, view_to_gocs );

// 仮の near, far を設定
camera.near = 30;
camera.far = 500000;
}


// 画像プロバイダを生成
createImageProvider()
{
return new mapray.StandardImageProvider( "https://cyberjapandata.gsi.go.jp/xyz/seamlessphoto/", ".jpg", 256, 2, 18 );
}
}


Expand Down
Loading