Verge3d + Blender: Interactive Table (web 3d/vr) — Step‑by‑step
Student Guide
This session introduces interactivity using Verge3D Puzzles.
Students learn how to assign materials to the metal stand by clicking on color
spheres and replace wood textures on the table by clicking on wood slabs. The
process covers exporting updated scenes, setting up puzzle logic, and testing
interactions for a fully responsive 3D experience.
Session 10A — Drawer Animation, Camera Limits, and
Optimization
Goal: Add click‑triggered animation for the drawer,
adjust camera controls for a better user experience, improve texture quality,
and enable compression for optimized web performance.
1) Trigger Drawer Animation with Puzzles
- Export
the scene as Verge3D glTF and open Puzzles from the App Manager.
- Create
a new tab in Puzzles (name it Animation).
- Drag
in a “when clicked” event → set object to Drawer.
- From
Animation, drag “play animation” → snap it under the event.
- Set
loop to once.
- Save
and Play → clicking the drawer plays the opening animation.
2) Add Open/Close Toggle Logic
- In Variables,
create a new variable: status.
- Set
initial status to closed (drag in set status to + text
block → type closed).
- Add
an if-do block from Logic:
- Condition:
if status = closed, play the open animation.
- On
the animation block, open its settings and enable “when finished”.
- Use
a set status to block to set status to open once the animation
finishes.
- Add
an else if condition:
- If status
= open, play the animation in reverse.
- Enable
advanced playback and set direction: reverse.
- On
completion, set status back to closed.
- Save
and Play → clicking toggles between opening and closing smoothly.
3) Adjust Light for Shadow Placement
- In
Blender, hide the environment sphere (viewport only).
- Select
the Sun Light, go to Top View, and use G (move) and R
(rotate) to adjust its angle.
- Preview
with Sneak Peek until the shadow falls in the desired direction.
- Save
and Export the scene again.
4) Limit Camera Zoom and Rotation
- Select
the Camera.
- In Camera
Properties → Verge3D Settings:
- Set
Minimum Distance = 2
- Set
Maximum Distance = 4
- Set
Vertical Rotation Limit = 0 to ~85°
- Save
and Sneak Peek → test that zoom and rotation are restricted
properly.
5) Improve Texture Quality
- Select
the Table_Main object.
- In
the Shader Editor, click on the Image Texture node for the
wood material.
- In
the Verge3D settings for the texture, set Anisotropic Filtering
to 8x.
- Save,
Export, and Sneak Peek → textures should now render sharper.
6) Enable Asset Compression
- In
Blender, go to Render Properties → Verge3D Settings.
- Enable
LZMA Compression.
- Save
and Export Verge3D glTF.
- In
Puzzles, open the Init tab.
- Drag
in Configure Application and enable Compressed Assets.
- Save
and Play → check the project folder; file sizes should be
significantly reduced (e.g., .bin file reduced from ~105 KB to ~18 KB).
7) Final Testing
- Open
the app from App Manager and test:
- Drawer
toggles open/close on click.
- Shadows
and textures look correct.
- Camera
zoom/rotation limits are enforced.
- File
sizes are optimized.
Mini‑Checklist
Next: Learn how to publish the optimized project to
your website or web server.
Session 10B — Drawer Click Animation (Toggle Open/Close)
Goal: Use Puzzles to play the drawer animation
on click, and toggle it open/closed using a state variable (no JavaScript).
1) Prep & Open Puzzles
- In Blender:
File → Save, then File → Export → Verge3D glTF (overwrite
the app scene file).
- In App
Manager, open your app → click Puzzles.
2) Create a New Puzzles Tab
- Click
the + at the top of Puzzles to create a new tab.
- Name
it animation (keeps logic organized).
3) Basic Click → Play Animation
- From
Events, drag when object clicked → set object to Drawer.
- From
Animation, drag play animation and snap it under the event.
- Set
Object to Drawer, Playback: Once.
- Save
and Play to test: clicking the drawer should open (plays
forward).
If it autoplays on load, recheck Session 6 to ensure Verge3D
Settings → Auto Start = Off for the Drawer.
4) Add a State Variable (open/closed)
- From
Variables, create a variable named status.
- Drag
set status to and place it near the top of the tab; set the value
to text closed.
5) If/Else Toggle Logic
- From
Logic, drag if do and place it above the play animation
block.
- From
Logic → Comparators, drag = (equals) into the if condition.
- Into
the left side of =, drop the status variable; right side
type text closed.
- Put
your existing play animation block inside the if.
- Click
the gear icon on play animation and enable when finished;
attach set status to open under it (so the state updates after
finishing).
- Click
the gear on the if block and add an else if.
- Duplicate
the = check and change the right side to open.
- Duplicate
the play animation block and place it inside the else if.
Click its gear → Advanced Playback and set it to reverse
(play from end to start). Alternatively, set Start = 30, End = 1, Speed
= 1.
- In
the else if branch’s when finished, set status back
to closed.
- Save
and Play to test: click → opens; click again → closes.
Troubleshooting
- Nothing
happens on click: Ensure the clicked object is Drawer and the
animation action exists on that object.
- Only
opens, never closes: Check that status is set to open in
the when finished slot and that the else if condition
compares to open.
- Reverse
doesn’t work: Use Advanced Playback → Reverse, or manually set Start/End
frames inverted.
Mini‑Checklist
Session 11 — Final Tweaks: Shadows, Camera Limits,
Texture Quality, Compression
Goal: Polish the visual feel (shadow direction), lock
down camera limits, boost texture clarity, and shrink file sizes for the web.
1) Nudge Shadow Direction (Sun Light)
- Temporarily
hide the background sphere (viewport icon) to see the light
clearly.
- Select
the Sun light.
- Top
View (Numpad 7) → G to move, R Z to rotate until the
shadow falls behind the table (check with Sneak Peek).
- When
satisfied, Save and Export Verge3D glTF.
Tip: Combine with Session 5 shadow settings (CSM Max
Distance, Contact Shadows) for crisp results.
2) Camera Orbit Limits (Verge3D Settings)
- Select
the Camera → Camera Properties → Verge3D Settings.
- Set
Min Distance = 2 and Max Distance = 4 (adjust to taste).
- Set
Vertical Rotation Limit range, e.g., 0° to 85° (prevents
diving under the ground).
- Save
and test with Sneak Peek (you shouldn’t be able to zoom too
close/far or go below the ground plane).
3) Sharper Textures (Anisotropic Filtering)
- Select
Table_Main (or the object using your primary wood texture
M_Wood_00).
- In Shader
Editor, click the Image Texture node (e.g., named wood).
- In
the side panel for that texture (Verge3D settings), set Anisotropic
Filtering = 8× (or 4× on low‑end devices).
- Save
and Sneak Peek to verify improved clarity at glancing angles.
4) Compress Assets (Smaller Web Downloads)
A) Export with LZMA
- In
Render Properties → Verge3D Settings, enable LZMA Compression.
- File
→ Save, then File → Export → Verge3D glTF (overwrite scene).
B) Enable Compressed Assets in Puzzles
- Open
Puzzles → init tab.
- From
Initialization, add/locate configure application and enable Compressed
Assets.
- Save
and Play.
C) Verify File Sizes
- In
your app folder, note that .bin and .gltf sizes should drop significantly
(e.g., from ~105 KB → ~18 KB, 28 KB → ~4 KB in the example).
5) Final Save, Export, Run
- Save
the .blend.
- Export
→ Verge3D glTF.
- In App
Manager, click Run to test the production‑like build.
Troubleshooting
- Camera
still goes under ground: Increase Vertical Rotation Limit lower
bound (e.g., 10–15°) or adjust target point (Session 3).
- Textures
still blurry at angles: Confirm you changed the Image Texture
node’s Verge3D anisotropy (not the World). Try 16× if available.
- Compression
not applied: Ensure you both enabled LZMA in Blender and
Compressed Assets in Puzzles → configure application, then
re‑exported.
Mini‑Checklist
Next: Publishing: package your app and deploy to
GitHub Pages/Netlify (or your server) with a short README and versioned assets.
No comments:
Post a Comment