ส่งออก GLB และนำเข้า Twin host
วิดีโอประกอบ
ดูบน YouTube (เปิดในแท็บใหม่)
-
BS-01: Introduction to Bitstream Studio ผศ.ดร.สันติ นุราช (KMUTT) -
BS-11: 3D Object Transform Drivers ผศ.ดร.สันติ นุราช (KMUTT) -
BS-13: Graphics Settings ผศ.ดร.สันติ นุราช (KMUTT) -
BS-14: Animation Player ผศ.ดร.สันติ นุราช (KMUTT) -
BS-15: Animation Clips & Mixers ผศ.ดร.สันติ นุราช (KMUTT)
วิดีโอโดย ผศ.ดร.สันติ นุราช ภาควิชาวิศวกรรมระบบควบคุมและเครื่องมือวัด คณะวิศวกรรมศาสตร์ มหาวิทยาลัยเทคโนโลยีพระจอมเกล้าธนบุรี (KMUTT) · ดูทั้งชุดใน playlist AIoT Foundation
Course 3 · Module 4
Suggested time: ประมาณ 3 ชั่วโมง — ส่งออก GLB จาก Blender นำเข้า Twin host กำหนดจุดเซ็นเซอร์/โต้ตอบ แล้วทดสอบกับ telemetry หรือคลิปแอนิเมชัน
Format: บทเรียนลงมือทำ — อ่านแล้วทำตามได้เลย; การจำลองสถานการณ์ใช้งานเต็มรูปแบบอยู่ที่ M05
Lab · Export checklist · ← Table of Contents · ← M03 · M05 →
เป้าหมาย (Learning Outcomes)
หัวข้อที่มีชื่อว่า “เป้าหมาย (Learning Outcomes)”เมื่อเรียนจบ คุณควรทำได้ดังนี้:
- ส่งออกโมเดลในรูปแบบ glTF/GLB (และทางเลือก FBX/OBJ) ให้พร้อมใช้กับ Twin
- นำโมเดลเข้าสู่ TESA Digital Twin ผ่านโฮสต์หลักของคอร์ส (Bitstream Studio)
- กำหนดจุดโต้ตอบ (interaction points) จุดเซ็นเซอร์ และตำแหน่งประกอบ
- ทดสอบโมเดลร่วมกับข้อมูล telemetry / การเคลื่อนไหว / ค่าเซ็นเซอร์
Key phrase
GLB ที่ดี = ขนาดถูก · แกนถูก · ชื่อคลิปชัด · วัสดุส่งออกได้ — นำเข้า Twin แล้วค่อยแต่งฉาก ไม่ใช่แก้สเกลทีหลังทีละร้อยเท่า
Read alongside this chapter
หัวข้อที่มีชื่อว่า “Read alongside this chapter”| Document | Use when |
|---|---|
| M03 — Motion and Interaction | คลิป lid_open / รายการ clip list |
| Course 2 M03 — Blender for Twin | ภาพรวม export GLB สั้น ๆ |
| glTF 2.0 exporter (Blender 4.5) | ตัวเลือก Mesh / Materials / Animations |
| glTF Animations | Stash Action · ชื่อคลิป |
| glTF Materials | Principled BSDF ที่ส่งออกได้ |
| Apply Scale | ก่อน export |
| Khronos glTF | มาตรฐานไฟล์ที่ Twin / เว็บใช้ |
| Bitstream Studio (Marketplace) | นำเข้า / แสดงโมเดล 3D + telemetry |
| ternion-3d-assets-free | ตัวอย่าง GLB อ้างอิงสเกลและวัสดุ |
| TESAIoT_Hackathon | web-app/ เช่น ex05 เทียบข้อมูลเซ็นเซอร์ |
| TESAIoT Developer Hub | อ้างอิงบอร์ดเมื่อจับคู่จุดเซ็นเซอร์ |
| Export checklist | แบบฟอร์มผลงาน |
1. What “Twin-ready” Means Here
หัวข้อที่มีชื่อว่า “1. What “Twin-ready” Means Here”ใน Course 3 โฮสต์ Digital Twin หลักคือ Bitstream Studio (VS Code extension) — รับไฟล์ glTF Binary (.glb) สำหรับ preview / Sensor Studio / Animation Lab ตามเครื่องมือที่มี
[Blender .blend] export glTF 2.0 │ ▼ enclosure_twin.glb │ ▼[Bitstream Studio / Twin host] place model · mark sensor/interaction · play clip │ ├── optional: live telemetry (Simulator or Board) └── optional: Hackathon web-app ex05 / ex06 as second screen| Format | Use when |
|---|---|
.glb |
เป้าหมายหลัก — ไฟล์เดียว รวม mesh + materials + animations |
.gltf + bins/textures |
เมื่อต้องการแยก texture แก้ไขภายนอก |
| FBX / OBJ | สำรองส่งเครื่องมืออื่น — ไม่ใช่เส้นทางหลักของ Twin เว็บ |
| STL | เก็บไว้พิมพ์ใน M06 — ไม่แทน GLB สำหรับ Twin |
มาตรฐาน: Khronos glTF
2. Prepare the Blend File Before Export
หัวข้อที่มีชื่อว่า “2. Prepare the Blend File Before Export”ทำตามลำดับนี้ทุกครั้งก่อนกด Export
2.1 Scale, origin, and cleanup
หัวข้อที่มีชื่อว่า “2.1 Scale, origin, and cleanup”| Step | Action | Why |
|---|---|---|
| 1 | ตรวจหน่วยทีมยังตรง M01 (Metric + mm + Unit Scale ที่ตกลง) | กันสเกลเพี้ยนใน Twin |
| 2 | Ctrl+A → Scale (และ Rotation ถ้าจำเป็น) บนชิ้นที่จะส่ง |
Apply |
| 3 | Origin ของฝาอยู่ที่บานพับ (จาก M03) | คลิปหมุนถูกจุด |
| 4 | ลบ/ซ่อน cutter, ไฟทดสอบ, กล้องที่ไม่ต้องการส่ง | ไฟล์เบาและไม่รก |
| 5 | ชื่อ object เป็นภาษาอังกฤษสั้น | อ้างใน Twin / checklist |
2.2 Materials that survive export
หัวข้อที่มีชื่อว่า “2.2 Materials that survive export”ใช้ Principled BSDF ตามที่ฝึกใน M02 — glTF รองรับพารามิเตอร์หลักได้ดี (glTF Materials)
| Do | Avoid for Twin export |
|---|---|
| Base Color / Roughness / Metallic ชัด | Shader ซับซ้อนที่ glTF ไม่รู้จัก |
| UV พอสำหรับลายสำคัญ (ถ้ามี texture) | พึ่งเฉพาะ procedural node ที่ bake ไม่ได้ |
| ทดสอบ Material Preview ก่อน export | สมมติว่า EEVEE กับ Twin เหมือนกันทุกอย่าง |
2.3 Animations that will be included
หัวข้อที่มีชื่อว่า “2.3 Animations that will be included”ตาม glTF Animations:
- Action จะถูกส่งออกถ้าเป็น active action หรือถูก Stash ลง NLA track
- ถ้ามีหลายคลิป (
lid_open,lid_close) ให้ Stash ให้ครบก่อน export - ชื่อ track/action มีผลต่อชื่อคลิปใน GLB — ใช้ชื่อเดียวกับ clip list
2.4 Optional: reduce polycount
หัวข้อที่มีชื่อว่า “2.4 Optional: reduce polycount”ถ้าไฟล์ใหญ่หรือ Twin กระตุก:
- ลด subdivision ที่ไม่จำเป็น
- อย่าลดจนช่องพอร์ตอ่านไม่ออก
- เปรียบเทียบขนาดไฟล์กับตัวอย่างใน ternion-3d-assets-free เป็นแนวคร่าว ๆ
3. Export glTF Binary (.glb) — Step by Step
หัวข้อที่มีชื่อว่า “3. Export glTF Binary (.glb) — Step by Step”อ้างอิงคู่มือเต็ม: glTF 2.0
- เลือกเฉพาะชิ้นที่จะส่ง (หรือส่งทั้ง scene ตามที่ทีมตกลง)
File → Export → glTF 2.0- Format: glTF Binary (.glb)
- แนะนำเปิดอย่างน้อย:
| Export option | Lab tip |
|---|---|
| Selected Objects (ถ้าเลือกชิ้นแล้ว) | กันพาไฟ/พื้นทดสอบไปด้วย |
| Data → Mesh → Apply Modifiers | ส่งผล Boolean/Solidify/Bevel ที่ยังไม่ Apply ในฉาก |
| Materials | รวม Principled |
| Animations (ถ้ามีคลิป M03) | เปิด และตรวจ Mode ตามด้านล่าง |
- Animation Mode (เมื่อมีหลายคลิป):
| Mode | Use when |
|---|---|
| Actions (default) | มี active action หรือ stash ใน NLA แล้ว |
| NLA Tracks | จัดการหลายแทร็กเป็นคลิปแยกชัด |
- ตั้งชื่อไฟล์ เช่น
enclosure_twin.glbแล้ว Export - ตรวจขนาดไฟล์และเปิดดูในเครื่องมือ preview ของระบบ (หรือ import กลับ Blender ชั่วคราว) ว่าคลิปยังเล่นได้
จดตัวเลือกที่ใช้จริงลง export-twin-checklist.md
4. Import into Bitstream Studio (Twin Host)
หัวข้อที่มีชื่อว่า “4. Import into Bitstream Studio (Twin Host)”4.1 Bring-up
หัวข้อที่มีชื่อว่า “4.1 Bring-up”- ติดตั้ง/เปิด Bitstream Studio จาก VS Code
- เปิด workspace ของคุณ (ทบทวนแนวทางโฮสต์จาก Course 2 ถ้าเคยเรียน)
- นำเข้าไฟล์
.glbตาม UI ของรอบนั้น เช่น- แผง Assets / Model / Free Loader
- หรือ Sensor Studio / 3D preview / Animation Lab
รายละเอียดปุ่มอาจต่างตามเวอร์ชัน — ให้ทำตามคู่มือของเวอร์ชันที่ใช้ และจดชื่อแผงที่ใช้ใน checklist
4.2 First checks after import
หัวข้อที่มีชื่อว่า “4.2 First checks after import”| Check | Pass means |
|---|---|
| Model visible | เห็นกล่องใน viewport |
| Scale usable | ไม่จิ๋ว/ยักษ์ผิดปกติเมื่อเทียบของจริงหรือ PCB ในใจ |
| Up-axis / orientation | วางบน “พื้น” ได้โดยไม่ต้องหมุนแก้ยาว |
| Named parts readable | แยกฝา/ฐานได้ถ้า Twin แสดง hierarchy |
| Animation (if exported) | เล่น lid_open ได้หรือมีรายการคลิป |
ถ้าสเกลผิดรอบเดียว: กลับไปแก้ใน Blender แล้ว export ใหม่ — อย่าซูมแก้ใน Twin แล้วถือว่าจบ (ยอมรับได้แค่เป็น workaround ชั่วคราวเท่านั้น)
4.3 Compare with a known-good GLB (optional)
หัวข้อที่มีชื่อว่า “4.3 Compare with a known-good GLB (optional)”โหลดโมเดลจาก ternion-3d-assets-free คู่กัน เพื่อเทียบว่า pipeline นำเข้าของเครื่องคุณทำงาน — จากนั้นสลับกลับไปโมเดลของคุณ
5. Interaction Points and Sensor Nodes
หัวข้อที่มีชื่อว่า “5. Interaction Points and Sensor Nodes”เป้าหมายของข้อนี้: ให้ทีมออกแบบกับทีมเฟิร์มแวร์พูดภาษาเดียวกัน
5.1 What to mark
หัวข้อที่มีชื่อว่า “5.1 What to mark”| Point type | Example on your enclosure | Link to firmware / Twin |
|---|---|---|
| Sensor node | ช่องเหนือ IMU / อุณหภูมิ | ชื่อเซ็นเซอร์ เช่น bmi270, sht40 |
| Interaction point | ฝา · ปุ่ม · LED window | คลิป lid_open · สถานะ LED |
| Mount / placement | ฐานวางโต๊ะ · รูสกรู | origin การวางในฉาก |
ในแล็บอย่างน้อยระบุ 1 จุด ที่อธิบายได้ชัด (ตำแหน่งบนโมเดล + ชื่อที่ผูกกับข้อมูล)
5.2 Naming convention (lab)
หัวข้อที่มีชื่อว่า “5.2 Naming convention (lab)”sensor_bmi270_slotsensor_sht40_ventinteract_lidinteract_user_buttonled_status_windowจดคู่ชื่อ ↔ ความหมายใน checklist — อย่าใช้ชื่อสุ่ม
5.3 How you “define” them in the lab
หัวข้อที่มีชื่อว่า “5.3 How you “define” them in the lab”ขึ้นกับเครื่องมือที่มี อย่างใดอย่างหนึ่งนับได้:
- Empty / locator ใน Blender ที่ export ไปด้วย
- โน้ตตำแหน่ง + สกรีนช็อตใน Twin
- การผูกคลิปแอนิเมชันหรือ material กับสถานะใน UI
สำคัญคือมีหลักฐานและชื่อคงที่ ไม่ใช่แค่ชี้ในอากาศตอนพรีเซนต์
6. Test with Telemetry or Motion Data
หัวข้อที่มีชื่อว่า “6. Test with Telemetry or Motion Data”6.1 Minimum test matrix
หัวข้อที่มีชื่อว่า “6.1 Minimum test matrix”| Test | How | Pass |
|---|---|---|
| A — Static placement | โมเดลนิ่งใน Twin | ขนาด/แกนใช้ได้ |
| B — Clip playback | เล่น lid_open ใน host |
ฝาเปิดตามที่ออกแบบ |
| C — Live or sim data (แนะนำ) | Link Simulator หรือ Board + ดู telemetry | ค่าเซ็นเซอร์ไหลขณะโมเดลอยู่บนจอ |
6.2 Suggested second screen — Hackathon web-app
หัวข้อที่มีชื่อว่า “6.2 Suggested second screen — Hackathon web-app”หลังโมเดลอยู่ใน Twin แล้ว (ไม่แทนขั้นตอน export):
- Serve โฟลเดอร์
web-app/จาก TESAIoT_Hackathon - เปิด ex05 (orientation) หรือ ex06 (dashboard) ตามเซ็นเซอร์ที่มี
- แคปคู่: Twin มีโมเดล + web-app มีค่า
ใช้สอนว่าโมเดล 3D เป็นเปลือกภาพ — ความจริงของเซ็นเซอร์อยู่ที่สตรีมข้อมูล (Course 2 M04 มี walkthrough ex05)
6.3 Example bindings (pick one)
หัวข้อที่มีชื่อว่า “6.3 Example bindings (pick one)”| If you have… | Binding idea |
|---|---|
| BMI270 stream | หมุน/เอียง preview ตาม orientation (ถ้า host รองรับ) หรือเทียบกับ ex05 |
| Threshold / mode event | เปลี่ยนสีส่วน led_status_window หรือเล่นคลิปสั้น |
| Lid interaction in UI | ปุ่มใน Twin สั่งเล่น lid_open |
ไม่ต้องครบทุกข้อใน 3 ชั่วโมง — เลือกอย่างน้อยหนึ่งเส้นทางที่มีหลักฐาน
7. Quality Gate Before M05
หัวข้อที่มีชื่อว่า “7. Quality Gate Before M05”| Check | Pass means |
|---|---|
.glb file exists |
ชื่อและที่เก็บจดใน checklist |
| Import OK in Bitstream Studio | สกรีนช็อต |
| Scale / axis usable | ไม่ต้องเดาสเกลใหม่ |
| ≥ 1 sensor or interaction point documented | ชื่อ + ตำแหน่ง |
| Clip names match M03 list (if any) | ไม่เปลี่ยนชื่อตอน export โดยไม่จด |
| Optional telemetry evidence | Studio และ/หรือ web-app |
Next Steps
หัวข้อที่มีชื่อว่า “Next Steps”- ทำแล็บ: แล็บ
- กรอก export-twin-checklist.md
- เมื่อพร้อม ไปต่อ M05 — Scenario and Digital Validation
References and Further Reading
หัวข้อที่มีชื่อว่า “References and Further Reading”Blender / glTF
หัวข้อที่มีชื่อว่า “Blender / glTF”- glTF 2.0 importer/exporter (4.5 LTS)
- glTF Animations
- glTF Materials
- Apply Scale
- Khronos glTF
- Blender Fundamentals — Importing & Exporting
Twin host and evidence
หัวข้อที่มีชื่อว่า “Twin host and evidence”- Bitstream Studio
- ternion-3d-assets-free
- TESAIoT_Hackathon —
web-app/ex05,ex06 - TESAIoT Developer Hub
- Course 2 M03 · Course 2 M04 · Course 3 TOC
เช็กความเข้าใจ
หัวข้อที่มีชื่อว่า “เช็กความเข้าใจ”คำถามสั้นสามข้อใน quiz.yaml ผูกกับเป้าหมายของบทเรียนนี้ข้อละหนึ่งคำถาม ลองตอบเองก่อน แล้วค่อยเทียบกับเฉลยและคำอธิบายในไฟล์
ลงมือต่อที่ แล็บ: ส่งออก GLB และนำเข้า Twin
Lab · Export checklist · ← TOC · ← M03 · M05 →
คำถามทบทวน
ลองตอบเองก่อน แล้วค่อยเปิดดูเฉลย
-
ถ้าต้องการให้ผลของ Boolean / Solidify / Bevel ที่ยังไม่ Apply ในฉากติดไปใน GLB ต้องเปิดตัวเลือกใด (เป้าหมายข้อ 1)
- Selected Objects
- Animations
- Materials
- Data → Mesh → Apply Modifiers
ดูเฉลย
คำตอบ: D. Data → Mesh → Apply Modifiers
ตาราง Export option ในหัวข้อ 3
-
ถ้านำเข้า Twin แล้วพบว่าสเกลผิด บทเรียนแนะนำให้ทำอย่างไร (เป้าหมายข้อ 2)
- ลบคลิปแอนิเมชันออก
- กลับไปแก้ใน Blender แล้ว export ใหม่
- ซูมแก้ใน Twin แล้วใช้ต่อถาวร
- เปลี่ยนไปส่ง STL แทน
ดูเฉลย
คำตอบ: B. กลับไปแก้ใน Blender แล้ว export ใหม่
หัวข้อ 4.2 First checks after import
-
ชื่อใดตรงกับรูปแบบการตั้งชื่อจุดของบทเรียน (เป้าหมายข้อ 3)
- `Point1`
- `จุดเซ็นเซอร์`
- `Cube.001`
- `sensor_sht40_vent`
ดูเฉลย
คำตอบ: D. `sensor_sht40_vent`
หัวข้อ 5.2 Naming convention: `sensor_…`, `interact_…`, `led_status_window`
อ้างอิงบทเรียนนี้
ถ้านำบทเรียนนี้ไปสอน ทำสไลด์ หรือทำเอกสารต่อ ให้อ้างอิงด้วยข้อความนี้ ถ้าดัดแปลงเนื้อหา ให้เติม (ดัดแปลง)ต่อท้ายชื่อบทเรียน
"ส่งออก GLB และนำเข้า Twin host" จาก TESA Open Knowledge โดยสมาคมสมองกลฝังตัวไทย (Thai Embedded Systems Association: TESA) https://github.com/tesaiot/tesa-qualification-program สัญญาอนุญาต CC BY-NC 4.0
ข้อความอ้างอิงภาษาอังกฤษ: "Exporting GLB and Importing into the Twin Host" from TESA Open Knowledge by the Thai Embedded Systems Association (TESA), https://github.com/tesaiot/tesa-qualification-program, licensed under CC BY-NC 4.0
ลิงก์บทเรียน: https://tesaiot.github.io/tesa-qualification-program/courses/product-design/m04-blender-to-twin/l01-blender-to-twin/
บทเรียนนี้ดัดแปลงจากต้นฉบับด้านล่าง เมื่ออ้างอิงให้คงเครดิตต้นฉบับไว้ด้วย
https://github.com/drsanti/TESAIoT-Courses/blob/287c21814ba8c75f693136616dcd270349a15966/C3/M04/README.md · Original content by Asst. Prof. Dr. Santi Nuratch (ผศ.ดร.สันติ นุราช), KMUTT. Course 3 (C3/) of drsanti/TESAIoT-Courses. TESA funded the work and holds the rights; published here under CC BY-NC 4.0. The upstream repository carries no licence file. Text kept faithful; structure, front matter, quizzes and notes added by TESA Open Knowledge.
TESA Open Knowledge · © 2026 สมาคมสมองกลฝังตัวไทย (TESA) · CC BY-NC 4.0
เนื้อหาเผยแพร่ภายใต้ CC BY-NC 4.0 นำไปใช้ต่อในงานที่ไม่ใช่เพื่อการค้าได้ โปรดอ้างอิงสมาคมสมองกลฝังตัวไทย (TESA) ทุกครั้ง · วิธีอ้างอิง TESA