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 にー兄さん
『Ground Truth: How We Create Geometrically Accurate Reconstructions (Niantic Spatial Blog)』 を読む / read Ground Truth: How We Create Geometrically Accurate Reconstructions
drumath2237
0
53
この時代にOSS開発に向き合ってみる / face the oss development in this era
drumath2237
0
41
プログラマの職能が代替可能になりつつあるこの時代でプログラムと向き合う修行を積む / dedicating myself to the discipline of programming
drumath2237
0
90
個人的3D Gaussian Splattingニュースをご紹介 / sharing 3d gaussian splatting news
drumath2237
0
560
Jetpack XR SDKから紐解くAndroid XR開発と技術選定のヒント / about-androidxr-and-jetpack-xr-sdk
drumath2237
1
670
XRエンジニアの視点から XRのイマと社会実装の実現について考える / thinking-about-xr-popularization
drumath2237
0
84
軽率にプログラミング言語のシンタックスについて考えてみよう / lets-think-about-programming-lang-syntax
drumath2237
0
110
エンジニアが軽率に趣味から始める、OSS貢献を軸とした個人活動 / oss-contribution-as-a-hoby-project
drumath2237
0
90
Babylon.js 8.0のアプデ情報を 軽率にキャッチアップ / catch-up-babylonjs-8
drumath2237
0
430
Other Decks in Programming
See All in Programming
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
760
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.1k
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
2
680
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
180
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
120
Oxcを導入して開発体験が向上した話
yug1224
4
310
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
350
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
200
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
340
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
140
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
240
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
130
Featured
See All Featured
Context Engineering - Making Every Token Count
addyosmani
9
970
Building an army of robots
kneath
306
46k
Ruling the World: When Life Gets Gamed
codingconduct
0
250
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
370
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
410
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
590
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
860
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
From π to Pie charts
rasagy
0
210
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
440
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
180
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を公開
最後に宣伝