Git Product home page Git Product logo

babylonjs-typescript-vite's Introduction

Vite + TypeScript + Babylon.js で WebAR を作る

WebAR を実行するために SSL 対応する

SSL でしか動かないので通常のローカルホスト立ち上げでは無く、証明書を作ってそれを使って立ち上げるようにする
以下のコマンドを叩いて key.pemcert.pem を生成して、npm run dev をしないと動かない
これをすれば手元のスマホでも起動しているURLでサイトを閲覧することができます

openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
  • Common Name? 以外は全部エンターでOK
  • 上記の質問だけローカルIPを回答する
  • npm run dev--host を追加して起動するとローカルIPが出てくるので package.jsonscript を修正して起動し直すと出てくる
  • 仮にローカルIPが 192.168.11.16 でホストが 3000 であれば、回答は https://192.168.11.16:3000 となる
  • これをすると cert.pemkey.pem が生成される
    • これらは各ローカルの情報になるので git 管理しないように注意
    • 後は vite.config.tsserver.https.keyserver.https.cert を設定する
import { defineConfig } from "vite";
import * as fs from "fs";

export default defineConfig({
  server: {
    https: {
      key: fs.readFileSync("./key.pem"),
      cert: fs.readFileSync("./cert.pem"),
    },
  },
});

メモ

  • Babylon.js で WebXR を作ろうとしたけど、iOS には対応していないらしい...
  • Android でも使う時に ARKit のアプリのインストールをしないといけない
  • それだけ精度が良いんだろうけど、Webの気軽さがないかもなぁと感じた

babylonjs-typescript-vite's People

Contributors

yuki-sakaguchi avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.