Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Vue・Babylon連携ライブラリ BabyuewJSについて / about-babyuewjs
Search
にー兄さん
November 22, 2023
Programming
260
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Vue・Babylon連携ライブラリ BabyuewJSについて / about-babyuewjs
社内勉強会で発表した資料です(公開許可済み)
にー兄さん
November 22, 2023
More Decks by にー兄さん
See All by にー兄さん
ついにAuraも登場したのでJetpack XR SDKについて今一度語りたい / i wanna talk about xreal aura
drumath2237
0
25
『Ground Truth: How We Create Geometrically Accurate Reconstructions (Niantic Spatial Blog)』 を読む / read Ground Truth: How We Create Geometrically Accurate Reconstructions
drumath2237
0
58
この時代にOSS開発に向き合ってみる / face the oss development in this era
drumath2237
0
46
プログラマの職能が代替可能になりつつあるこの時代でプログラムと向き合う修行を積む / dedicating myself to the discipline of programming
drumath2237
0
97
個人的3D Gaussian Splattingニュースをご紹介 / sharing 3d gaussian splatting news
drumath2237
0
600
Jetpack XR SDKから紐解くAndroid XR開発と技術選定のヒント / about-androidxr-and-jetpack-xr-sdk
drumath2237
1
730
XRエンジニアの視点から XRのイマと社会実装の実現について考える / thinking-about-xr-popularization
drumath2237
0
89
軽率にプログラミング言語のシンタックスについて考えてみよう / lets-think-about-programming-lang-syntax
drumath2237
0
120
エンジニアが軽率に趣味から始める、OSS貢献を軸とした個人活動 / oss-contribution-as-a-hoby-project
drumath2237
0
98
Other Decks in Programming
See All in Programming
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
2.8k
20260623_Loop Engineeringで自分の分身の問い合わせBotを作る
ryugen04
0
230
どこまでゆるくて許されるのか
tk3fftk
0
520
フィードバックで育てるAI開発
kotaminato
1
120
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
180
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
530
AI 輔助遺留系統現代化的經驗分享
jame2408
1
1.2k
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
1.1k
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
890
act1-costs.pdf
sumedhbala
0
240
5分で問診!Composer セキュリティ健康診断
codmoninc
0
490
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
1.5k
Featured
See All Featured
The Curious Case for Waylosing
cassininazir
1
440
How GitHub (no longer) Works
holman
316
150k
The Language of Interfaces
destraynor
162
27k
[SF Ruby Conf 2025] Rails X
palkan
2
1.2k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
180
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
410
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Speed Design
sergeychernyshev
33
1.9k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
550
Transcript
Vue・Babylon連携ライブラリ BabyuewJSについて にー兄さん
アジェンダ 前提知識(Vue・Babylonについて) BabyuewJSについて おわりに
前提知識
主題 今回の話は Vue3とBabylon.jsをいい感じに組み合わせたい という話です
主題 今回の話は Vue3とBabylon.jsをいい感じに組み合わせたい という話です 本題に入る前に これらについて簡単に解説
Vue.js(https://ja.vuejs.org/) モダンJSフレームワーク(The Progressive JavaScript Framework) 類似ライブラリには React, Svelte, Angular, Solid,
… 最新はv3。v2とは「ほぼ別ライブラリ」 リポジトリ(https://github.com/vuejs/core) Start数は⭐41.4Kらしい(Reactは215K)
コード例(動作デモ) JavaScript, HTML, CSS が一体化したような .vueファイル JS側の変数を HTMLに埋め込んだり 変更を検知して 自動でUIを更新できる
<script setup> import { ref } from 'vue' const count = ref(0) </script> <template> <button @click="count++">Count is: {{ count }}</button> </template> <style scoped> button { font-weight: bold; } </style>
Babylon.js(https://www.babylonjs.com/) WebGLフレームワーク、Web 3Dエンジン、説明ちょっと迷う 類似ライブラリはThree.js Webで動くリアルタイム3Dアプリケーションを開発できる TypeScriptフルサポート リポジトリ(https://github.com/BabylonJS/Babylon.js) Star数は⭐21.7K(Three.jsは95.8K)
コード例(動作デモ) canvas要素を使って初期化 カメラ、ライト、Cubeを 配置してレンダリングを実行 const engine = new Engine(renderCanvas, true);
const scene = new Scene(engine) scene.createDefaultCameraOrLight(true, true, true) scene.createDefaultEnvironment() const box = MeshBuilder.CreateBox("box", {size:0.3}) box.position= new Vector3(0,0.15,0) window.addEventListener('resize', () => { engine.resize(); }); engine.runRenderLoop(() => { scene.render(); });
2つのライブラリの連携と BabyuewJSについて
JS FWとWebGL FWを組み合わせるって? つまり…… モダンWebフロントエンドPJで リアルタイム3D表現を扱いたい (いい感じに)
Babylon.jsのdocsにも一応書いてある How to use BabylonJS with Vue https://doc.babylonjs.com/communityExtensions/ Babylon.js+ExternalLibraries/BabylonJS_and_Vue/ BabylonJS_and_Vue_1
つまりscriptの中に 書けばいいじゃん もうちょっといい感じにしたい <script> import { ref, onMounted } from "@vue/runtime-core"; import { createScene } from "../scenes/MyFirstScene"; export default { name: "BabylonScene", setup() { const bjsCanvas = ref(null); onMounted(() => { if (bjsCanvas.value) { createScene(bjsCanvas.value); } }); return { bjsCanvas, }; }, }; </script>
いい感じとは、つまりreact-three-fiber R3F(https://docs.pmnd.rs/react-three-fiber/) export default function App() { return ( <Canvas>
<ambientLight intensity={0.5} /> <spotLight position={[10, 10, 10]} angle={0.15} penumbra={1} /> <pointLight position={[-10, -10, -10]} /> <Box position={[-1.2, 0, 0]} /> <Box position={[1.2, 0, 0]} /> </Canvas> ) } - シーンの状態が分かりやすい - ReactのI/Fで記述できてよい
R3FをVue3とBabylon.jsでも使いたい 100%この要件を満たす物はなかった → 作るか!w BabyuewJS v1.0.0-alpha.1が誕生 npm: https://www.npmjs.com/package/@babyuewjs/core repo: https://github.com/drumath2237/BabyuewJS
コード例(動作デモ) BabyuewSceneコンポーネント をscriptに配置 その中にオブジェクトを 配置していく propsは一部リアクティブ <template> <BabyuewScene antialias> <ArcRotateCamera
name="camera" :alpha="Math.PI / 3" :beta="Math.PI / 3" :radius="0.5" :target="[0, 0.05, 0]" > </ArcRotateCamera> <DirectionalLight :direction="[0.25, -1, -0.6]" :intensity="1" ></DirectionalLight> <Box name="my-box" :position="[0, 0.05, 0]" :size="0.1"> </Box> </BabyuewScene> </template>
おわりに
Babylon.jsが抱える問題と解決 Unityとは違いGUIエディタがない(一応存在する) 全部コードベースで扱う必要がある → シーンオーサリングと振る舞いの記述が混ざる →VueのSFCだとシーン表現と振る舞いの記述を分離できる Webと3D両方わかる必要がある →人口が多いWebの人を呼び込みたい →VueのI/Fで手軽に扱えるようにした
この先 まだ alpha版 仕組みはできたが機能は全然足りない のびしろ・改善点 たくさん Projectsを公開
最後に宣伝