unity3d - 是否可以从 Decentraland 访问/下载 glb 或 gltf 模型?

标签 unity3d unity-webgl decentraland

我使用 dcl initdcl start 创建了一个虚拟场景,并从他们的一个 github repositories 导入了一些模型.

我创建了一个创建场景的小脚本,将这些模型导入场景,控制台记录我导入场景的模型列表:

...

const trashCan = addToScene("trashCan", "models/Trash_Can.glb", new Transform({
    position: new Vector3(0.2, 0.2, 0.2),
    rotation: new Quaternion(0, 0, 0, 1),
    scale: new Vector3(1, 1, 1)
}));

trashCan.addComponent(
    new OnPointerDown((): void => {
        console.log("Downloadable entities:");

        // console.log(engine.entities);

        for (let k in engine.entities) {
            // console.log(engine.entities[k])
            // console.log(engine.entities[k].components)
            const shape = engine.entities[k].components["engine.shape"]
            const transform = engine.entities[k].components["engine.transform"]
            if (shape) {
                // console.log(engine.entities[k].components["engine.shape"].data)
                console.log("    name:     " + shape.src)
            }

            if (transform) {
                console.log("    position: " + transform.position)
            }
        }
    })
)

...

该脚本让我可以访问一些模型元数据,即项目中的模式路径及其在场景中的变换矩阵:

enter image description here

我想知道是否可以访问/下载 3D 模型。

是否有可能访问这些 3D 模型,也许 GET 它们?有人知道 Decentraland 是否禁止这种做法吗?据我所知,他们使用的是 Unity 引擎。

只是对场景中的其中一个模型执行 GET 似乎并不成功:

enter image description here

这有可能实现吗?

编辑:

在@cachius 的回答后,按照他的建议,我找到了以下内容:

enter image description here

unity.data(#1) 文件是一个 UnityWebData1.0 文件,可以使用 UnityPack 解压如所述here :

from unitypack.utils import BinaryReader

SIGNATURE = 'UnityWebData1.0'

class DataFile:
    def load(self, file):
        buf = BinaryReader(file, endian="<")
        self.path = file.name

        self.signature = buf.read_string()
        header_length = buf.read_int()
        if self.signature != SIGNATURE:
            raise NotImplementedError('Invalid signature {}'.format(repr(self.signature)))

        self.blobs = []
        while buf.tell() < header_length:
            offset = buf.read_int()
            size = buf.read_int()
            namez = buf.read_int()
            name = buf.read_string(namez)
            self.blobs.append({ 'name': name, 'offset': offset, 'size': size })
        if buf.tell() > header_length:
            raise NotImplementedError('Read past header length, invalid header')

        for blob in self.blobs:
            buf.seek(blob['offset'])
            blob['data'] = buf.read(blob['size'])
            if len(blob['data']) < blob['size']:
                raise NotImplementedError('Invalid size or offset, reading past file')


import os
f = open('unity.data', 'rb')
df = DataFile()
df.load(f)
EXTRACTION_DIR = 'extracted'
for blob in df.blobs:
    print('extracting @ {}:\t{} ({})'.format(blob['offset'], blob['name'], blob['size']))
    dest = os.path.join(EXTRACTION_DIR, blob['name'])
    os.makedirs(os.path.dirname(dest), exist_ok=True)
    with open(dest, 'wb') as f:
        f.write(blob['data'])

提取的数据文件夹包含一个或多个 .unity3d 文件,可以使用 AssetStudio 进一步解压这些文件,但是该工具对我来说看起来有点错误/不稳定,不确定它的可靠性。

根据我的发现,它包含大部分场景辅助实体,但模型。这些模型以 gltf 格式(#2)单独下载。只需下载文件并使用 Blender 将其导入即可。

因此 gltf 模型似乎位于 http://127.0.0.1:8001/content/contents/ 并且文件已重命名。我还无法检索关于 http://127.0.0.1:8001/content/contents 的确切内容的元数据,所以我会继续挖掘。

最佳答案

访问

查看模型是否在“网络”选项卡中显示为请求。如果是这样,您可以右键单击并“复制为 curl”,通过添加 > model.glb 在命令行中下载它们。这样您就可以应用与客户端相同的 header 和参数。

合法性

他们提供的内容用户提供的内容之间似乎有重要区别。他们的相关部分 Terms ,为清楚起见编辑了法律术语:

1。接受条款

Decentraland 基金会拥有 DCL 客户端、桌面客户端、SDK 5.0、市场、构建器、命令行界面、DAO 和开发者中心的权利,这些在本文中称为“工具” .

12。所有权

12.1 工具的所有权利归基金会所有。除非在第 13 条中获得授权,否则您同意不复制、修改、分发、执行、展示或创建基于工具的衍生作品。视觉界面、图形(包括与工具相关的所有艺术和绘图)以及代码和数据,不包括用户提交的内容,均归基金会所有。 ... 您同意,除这些条款中明确包含的内容外,对 LAND 的任何“购买”均不授予您对与其中的工具和内容相关的艺术和绘图的权利。未经基金会书面同意,您无权复制基金会 Material 。

13。开源许可证。

13.1 版权许可的授予。

每个贡献者都授予您复制、准备衍生作品、公开展示、公开表演、再许可和分发源或对象形式的作品和此类衍生作品的版权许可。

13.3 再分配。

只要您满足以下条件,您就可以在任何媒体中以源代码或对象形式复制和分发副本或衍生作品,无论是否修改:

  1. 修改不得违反隐私和内容政策,也不得违反或违反第 12.3 节,并要求任何其他贡献者遵守这些限制;
  2. 任何修改只能在向公众发布后六 (6) 个月后进行;
  3. 您必须向任何其他接收者提供本许可的副本;
  4. 您必须使任何已修改的文件带有醒目的通知,说明您更改了文件;
  5. 您必须在任何衍生作品中保留来源的所有版权、专利、商标和归属声明
  6. 如果作品包含“通知”文本文件,则任何衍生作品都必须在其中包含归属通知的副本。 ...

您应该通过 Discord 直接联系他们或他们的社区Twitter Reddit TelegramGitHub并在此处添加结果。

关于unity3d - 是否可以从 Decentraland 访问/下载 glb 或 gltf 模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72091515/

相关文章:

javascript - 更改页面时如何清理和卸载 Unity WebGL Canvas

unity3d - 在运行时从 persistentDataPath 加载音频(Unity3d WebGL)

unity3d - 如何在运行时向 Unity Tilemap 添加可编写脚本的磁贴?

c# - 在 Unity/C# 中,.Net 的 async/await 是否真的启动了另一个线程?

c# - 打字时如何设置 VSCode 以在 C# 和 C++ 中的新行上放置花括号?

c# - 统一: How to save and load scenes according to player progress

html - 如何解决 WebGL Unity 游戏中的这个错误?