[TOC]
You can download the library from github to local (e.g. C:/Users/Public/Documents/GitHub).
- clone from github https://github.com/emscripten-core/emsdk.
- execute install, activate and env.bat command (below command are on windows10 version, detail and another OS command is here).
$ emsdk install 1.39.7
$ emsdk activate 1.39.7
$ emsdk_env.bat
- Install MinGW EmscriptenとCMakeでのビルド方法
- set path of "C:\MinGW\bin"
Download nginx from http://nginx.org/download/nginx-1.18.0.zip , then unzip it.
Run command start nginx.exe
Access to http://localhost/ on web browser. You can see Welcome to nginx!
message if nginx work.
if you want to stop nginx, run command nginx -s stop
or nginx -s quit
.
nginxからgithub上のhtmlファイルを直接参照できるように設定を変更する。
- nginx コマンド超シンプル早見表 - Qiita
- nginx 公開ディレクトリの変更 - Qiita
- How to use nginx "root" and "location" on windows? - Stack Overflow
手順
-
nginx-1.18.0\conf\nginx.conf
のファイルを開く -
http → server内のlocationの項目を追加する
# "C:\Users\Public\Documents\GitHub\web_assembly_sample\samples\threejs\"内にあるhtmlファイルを参照したい場合 location /threejs/ { root C:\\Users\\Public\\Documents\\GitHub\\web_assembly_sample\\samples; } # "C:\Users\Public\Documents\GitHub\web_assembly_sample\samples\webasm\"内にあるhtmlファイルを参照したい場合 location /webasm/ { root C:\\Users\\Public\\Documents\\GitHub\\web_assembly_sample\\samples; } # You have to use this location, if you use GitHub/three.js repository libraries location /GitHub/ { root C:\\Users\\Public\\Documents; }
-
localhost/threejs/index.html
のようにファイルにアクセスできる/threejs
が来ると自動的に設定したrootパスが付加される仕組み※ モジュールをimportする場合、locationより上のディレクトリのファイルは読めないので注意
※ HTML内にscriptを直接記述する場合はモジュールで親ディレクトリ読むことはできない(同じディレクトリのモジュールを呼び出して、その中で親ディレクトリからimportする)
-
nginx.exe -s reload
で設定をリロード
note : cout, printf文は改行コードを入れないとconsoleに出力されない
- template with cmake : CODE
- IDEで自動補完を使えるようにする : CODE
- C++のVectorデータをjs側に渡す : CODE
- jsのデータをC++側に渡す : CODE
- jsの変数を直接C++で使う(
emscripten::val
型) : CODE <script type="module">
でimportする : [CODE]
- template with MeshLab : CODE
- load file in three.js and pass data to MeshLab : CODE
- read mesh data from MeshLab : CODE
- call functions of MeshLab : [CODE]
Basic usages are here.