正在加载视频...

视频加载失败

I’ve been making a new world building engine in Three.js and thought I’d share some of the crazy milestones I’ve achieved so far… 🧵

340,783 次观看 • 2 年前 •via X (Twitter)

15 条评论

ashxn 的头像
ashxn2 年前

First, people need avatars, so I made it so that you can drag and drop VRMs. Pretty simple stuff so far.

ashxn 的头像
ashxn2 年前

Avatars need locomotion, so based on your input a specific “emote” is lazy-loaded, retargeted and animated onto each avatar on the fly.

ashxn 的头像
ashxn2 年前

Skinned mesh animations are expensive due to all the bone matrix math, so we throttle updates based on distance. Far away avatars run animations at lower framerates. This lets us have 150-300 unique, independently animated @forgottenrunes avatars in the world at once.

ashxn 的头像
ashxn2 年前

Next is world building. I added support for dragging and dropping 3D models such as GLB and VOX. You can right click things to move and duplicate them etc.

ashxn 的头像
ashxn2 年前

World building often involves picking a “palette” of models and then placing down hundreds or thousands of them. Doing this the naive way will quickly exhaust our draw calls and CPU limit.

ashxn 的头像
ashxn2 年前

The way Unity handles this is by disconnecting the scene graph from the renderer. I built a new scene graph for ThreeJS that works the same way, by batching and instancing everything together behind the scenes.

ashxn 的头像
ashxn2 年前

We still have this concept of an “object” made up of many meshes, but behind the scenes its updating individual instances in their respective batches.

ashxn 的头像
ashxn2 年前

Now that we can place thousands of objects, it’s a waste of resources to render distant objects at full resolution. I made it so you can “tag” meshes in blender with a LOD distance, letting you render low poly lods far away or completely hide small objects at a certain distance.

ashxn 的头像
ashxn2 年前

Tagging meshes is ultra useful, I added additional tags for physics collision and wind effects too.

ashxn 的头像
ashxn2 年前

It’s now possible to have a ridiculous number of objects in the world, leading to super expensive raycasting. By default, ThreeJS raycasts against everything in the scene.

ashxn 的头像
ashxn2 年前

To fix this, I made the new scene graph insert everything into an octree and ran raycasts against that instead. Regular octrees suffer if you have lots of moving objects, so I had to create my own “loose” octree. Raycasting is now essentially free!

ashxn 的头像
ashxn2 年前

Now that we can make huge amazing looking worlds, we need more interactivity to make things fun. I made it so that each object can have an optional script. You can edit this live in the browser, with other people in realtime.

ashxn 的头像
ashxn2 年前

Each script runs in its own secure sandbox that can only manipulate its own meshes etc. The goal here is to allow people to create, collect and use objects across any world. You can think of each object as being its own web browser tab, completely isolated from other tabs.

ashxn 的头像
ashxn2 年前

I made it possible for scripts to be able to sit idle until needed. This allowed me to place 20k interactive trees that can all be chopped down.

ashxn 的头像
ashxn2 年前

Overall I’m pretty optimistic about where this is heading. If you have any questions I’ll try to answer them all below!

相关视频