merge ws/video2
This commit is contained in:
commit
c5f27770fc
63 files changed
+12207
-1509
No files matched your search
+28
-1
@@ -275,7 +275,7 @@ single-stream archive such as `.tar.gz` loads as the archive inside. A music fil
|
||||
|
||||
| Host | Files | Bridges |
|
||||
|---|---|---|
|
||||
| Roblox | none: pass buffers or strings | `F.host.toEditableImage(img)` |
|
||||
| Roblox | none: pass buffers or strings | `F.host.toEditableImage(img)`, `F.host.meshPages(prim)` / `F.host.toEditableMesh(prim, page)` |
|
||||
| LÖVE | `love.filesystem` (the game folder and the save directory), then `io` | `F.host.toImageData(img)`, `F.host.fromImageData(imageData)`, `F.host.toSoundData(audioOrDecoder)` |
|
||||
| LuaJIT | `io.open` | |
|
||||
| luau CLI | none | |
|
||||
@@ -304,6 +304,33 @@ label.ImageContent = Content.fromObject(editable)
|
||||
label.Parent = script.Parent -- a ScreenGui
|
||||
```
|
||||
|
||||
Meshes: one EditableMesh holds about 20k triangles and 60k vertices, and a client has only 8 growable ones at a time.
|
||||
`F.host.meshPages(prim, opts?)` splits a triangle primitive (`F.ops.mesh.merge` output) into runs that fit;
|
||||
`F.host.toEditableMesh(prim, page, opts?)` builds one page (positions relative to the returned centre, normals, uvs,
|
||||
sRGB vertex colours from the linear `COLOR_0`) and returns `editableMesh, centre`. Freeze each page into what you keep
|
||||
before building the next. Options: `scale` (number or `{ x, y, z }`), `doubleSided` (back faces, counted by
|
||||
`meshPages` too), `texCoord`, `flipV`, `normals` / `uvs` / `colors = false`, `yield` (called every `yieldEvery` = 2000
|
||||
triangles), `editableMesh` (append to an existing mesh). `F.host.pageData(prim, page, opts?)` is the same page as flat
|
||||
number arrays, without engine calls. Roblox is y up like glTF: put z-up scenes (STL, VOX, CAD) through
|
||||
`F.ops.mesh.setUp(scene, "y")` before merging.
|
||||
|
||||
<!-- doc:display needs Roblox -->
|
||||
```luau
|
||||
local AssetService = game:GetService("AssetService")
|
||||
local scene = assert(F.model.load(glbBytes))
|
||||
for _, prim in assert(F.ops.mesh.merge(scene, { byMaterial = true })) do
|
||||
for _, page in assert(F.host.meshPages(prim)) do
|
||||
local em, centre = assert(F.host.toEditableMesh(prim, page, { scale = 1 / 0.28 })) -- metres -> studs
|
||||
local fixed = AssetService:CreateEditableMeshAsync(Content.fromObject(em), { FixedSize = true })
|
||||
em:Destroy() -- frees the growable slot
|
||||
local part = AssetService:CreateMeshPartAsync(Content.fromObject(fixed))
|
||||
part.Position = Vector3.new(centre[1], centre[2], centre[3])
|
||||
part.Anchored = true
|
||||
part.Parent = workspace
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
**LÖVE.** `toImageData` copies an `rgba8` image into an `ImageData` (through the FFI), `fromImageData` copies back,
|
||||
and `toSoundData` turns an `Audio` or a `Decoder` (read to its end) into 16-bit `SoundData`:
|
||||
|
||||
|
||||
Reference in new issue
Block a user