playcanvas / playcanvas/editor

Non-preloaded material assets shouldn't be in the config.json asset registry

Open
#993 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: assets area: publishing enhancement
Dominant language
TypeScript
Stars
1.3k
Forks
215
Avg merge
1d 29m
Merged PRs (30d)
30

Description

If a material asset is not marked as preloaded, the full data is still in the asset registry of config.json (published build) and is parsed on startup as part of the preload process.

This should be separated into another JSON file like templates to save both size and JSON parse time.

A material asset is ~350 lines of JSON compared to others that are 10-15 lines

        "123855859": {
            "name": "Stone",
            "type": "material",
            "file": null,
            "data": {
                "shader": "blinn",
                "blendType": 3,
                "cull": 1,
                "useLighting": true,
                "twoSidedLighting": false,
                "useMetalness": true,
                "useMetalnessSpecularColor": false,
                "depthWrite": true,
                "emissiveTint": false,
                "glossInvert": true,
                "clearCoatGlossInvert": false,
                "sheenGlossInvert": false,
                "useDynamicRefraction": false,
                "useSheen": false,
                "diffuseTint": true,
                "specularTint": false,
                "sheenTint": false,
                "useIridescence": false,
                "metalness": 0,
                "shininess": 50,
                "opacity": 1,
                "bumpMapFactor": 1,
                "reflectivity": 1,
                "alphaTest": 0,
                "clearCoat": 0,
                "clearCoatGloss": 1,
                "clearCoatBumpiness": 1,
                "specularityFactor": 1,
                "refractionIndex": 0.666667,
                "refraction": 0,
                "sheenGloss": 0,
                "thickness": 0,
                "attenuationDistance": 0,
                "emissiveIntensity": 1,
                "iridescence": 0,
                "iridescenceRefractionIndex": 0.666667,
                "iridescenceThicknessMin": 0,
                "iridescenceThicknessMax": 0,
                "ambient": [
                    0.5,
                    0.5,
                    0.5
                ],
                "diffuse": [
                    0.472677,
                    0.510881,
                    0.528821
                ],
                "emissive": [
                    0,
                    0,
                    0
                ],
                "specular": [
                    1,
                    1,
                    1
                ],
                "sheen": [
                    1,
                    1,
                    1
                ],
                "attenuation": [
                    1,
                    1,
                    1
                ],
                "ambientTint": false,
                "aoMap": null,
                "aoMapChannel": "r",
                "aoMapUv": 0,
                "aoMapTiling": [
                    1,
                    1
                ],
                "aoMapOffset": [
                    0,
                    0
                ],
                "aoMapRotation": 0,
                "diffuseMap": null,
                "diffuseMapChannel": "rgb",
                "diffuseMapUv": 0,
                "diffuseMapTiling": [
                    1,
                    1
                ],
                "diffuseMapOffset": [
                    0,
                    0
                ],
                "diffuseMapRotation": 0,
                "specularMap": null,
                "specularMapChannel": "rgb",
                "specularMapUv": 0,
                "specularMapTiling": [
                    1,
                    1
                ],
                "specularMapOffset": [
                    0,
                    0
                ],
                "specularMapRotation": 0,
                "specularAntialias": true,
                "occludeSpecular": 1,
                "specularityFactorMap": null,
                "specularityFactorMapChannel": "r",
                "specularityFactorMapUv": 0,
                "specularityFactorMapTiling": [
                    1,
                    1
                ],
                "specularityFactorMapOffset": [
                    0,
                    0
                ],
                "specularityFactorMapRotation": 0,
                "enableGGXSpecular": false,
                "anisotropy": 0,
                "metalnessMap": null,
                "metalnessMapChannel": "r",
                "metalnessMapUv": 0,
                "metalnessMapTiling": [
                    1,
                    1
                ],
                "metalnessMapOffset": [
                    0,
                    0
                ],
                "metalnessMapRotation": 0,
                "conserveEnergy": true,
                "glossMap": null,
                "glossMapChannel": "r",
                "glossMapUv": 0,
                "glossMapTiling": [
                    1,
                    1
                ],
                "glossMapOffset": [
                    0,
                    0
                ],
                "glossMapRotation": 0,
                "clearCoatMap": null,
                "clearCoatMapChannel": "r",
                "clearCoatMapUv": 0,
                "clearCoatMapTiling": [
                    1,
                    1
                ],
                "clearCoatMapOffset": [
                    0,
                    0
                ],
                "clearCoatMapRotation": 0,
                "clearCoatVertexColor": false,
                "clearCoatVertexColorChannel": "r",
                "clearCoatGlossMap": null,
                "clearCoatGlossMapChannel": "r",
                "clearCoatGlossMapUv": 0,
                "clearCoatGlossMapTiling": [
                    1,
                    1
                ],
                "clearCoatGlossMapOffset": [
                    0,
                    0
                ],
                "clearCoatGlossMapRotation": 0,
                "clearCoatGlossVertexColor": false,
                "clearCoatGlossVertexColorChannel": "r",
                "clearCoatNormalMap": null,
                "clearCoatNormalMapUv": 0,
                "clearCoatNormalMapTiling": [
                    1,
                    1
                ],
                "clearCoatNormalMapOffset": [
                    0,
                    0
                ],
                "clearCoatNormalMapRotation": 0,
                "sheenMap": null,
                "sheenMapChannel": "rgb",
                "sheenMapUv": 0,
                "sheenMapTiling": [
                    1,
                    1
                ],
                "sheenMapOffset": [
                    0,
                    0
                ],
                "sheenMapRotation": 0,
                "sheenGlossMap": null,
                "sheenGlossMapChannel": "r",
                "sheenGlossMapUv": 0,
                "sheenGlossMapTiling": [
                    1,
                    1
                ],
                "sheenGlossMapOffset": [
                    0,
                    0
                ],
                "sheenGlossMapRotation": 0,
                "fresnelModel": 0,
                "emissiveMap": null,
                "emissiveMapChannel": "rgb",
                "emissiveMapUv": 0,
                "emissiveMapTiling": [
                    1,
                    1
                ],
                "emissiveMapOffset": [
                    0,
                    0
                ],
                "emissiveMapRotation": 0,
                "normalMap": null,
                "normalMapUv": 0,
                "normalMapTiling": [
                    1,
                    1
                ],
                "normalMapOffset": [
                    0,
                    0
                ],
                "normalMapRotation": 0,
                "refractionMap": null,
                "refractionMapChannel": "r",
                "refractionMapUv": 0,
                "refractionMapTiling": [
                    1,
                    1
                ],
                "refractionMapOffset": [
                    0,
                    0
                ],
                "refractionMapRotation": 0,
                "refractionVertexColor": false,
                "refractionVertexColorChannel": "r",
                "thicknessMap": null,
                "thicknessMapChannel": "r",
                "thicknessMapUv": 0,
                "thicknessMapTiling": [
                    1,
                    1
                ],
                "thicknessMapOffset": [
                    0,
                    0
                ],
                "thicknessMapRotation": 0,
                "thicknessVertexColor": false,
                "thicknessVertexColorChannel": "r",
                "iridescenceMap": null,
                "iridescenceMapChannel": "r",
                "iridescenceMapUv": 0,
                "iridescenceMapTiling": [
                    1,
                    1
                ],
                "iridescenceMapOffset": [
                    0,
                    0
                ],
                "iridescenceMapRotation": 0,
                "iridescenceThicknessMap": null,
                "iridescenceThicknessMapChannel": "r",
                "iridescenceThicknessMapUv": 0,
                "iridescenceThicknessMapTiling": [
                    1,
                    1
                ],
                "iridescenceThicknessMapOffset": [
                    0,
                    0
                ],
                "iridescenceThicknessMapRotation": 0,
                "heightMap": null,
                "heightMapChannel": "r",
                "heightMapUv": 0,
                "heightMapTiling": [
                    1,
                    1
                ],
                "heightMapOffset": [
                    0,
                    0
                ],
                "heightMapRotation": 0,
                "heightMapFactor": 1,
                "alphaToCoverage": false,
                "alphaFade": 1,
                "opacityMap": null,
                "opacityMapChannel": "r",
                "opacityMapUv": 0,
                "opacityMapTiling": [
                    1,
                    1
                ],
                "opacityMapOffset": [
                    0,
                    0
                ],
                "opacityMapRotation": 0,
                "opacityFadesSpecular": true,
                "sphereMap": null,
                "cubeMap": null,
                "cubeMapProjection": 0,
                "cubeMapProjectionBox": {
                    "center": [
                        0,
                        0,
                        0
                    ],
                    "halfExtents": [
                        0.5,
                        0.5,
                        0.5
                    ]
                },
                "lightMap": null,
                "lightMapChannel": "rgb",
                "lightMapUv": 0,
                "lightMapTiling": [
                    1,
                    1
                ],
                "lightMapOffset": [
                    0,
                    0
                ],
                "lightMapRotation": 0,
                "depthTest": true,
                "useFog": true,
                "useSkybox": true,
                "useGammaTonemap": true
            },
            "preload": true,
            "tags": [],
            "i18n": {},
            "id": "123855859"
        },
        "123855860": {
            "name": "axeDouble_uncommon.gltf.glb",
            "type": "container",
            "file": {
                "hash": "332c8aa1346488c566b54499d55e75a7",
                "size": 22400,
                "filename": "axeDouble_uncommon.gltf.glb",
                "url": "files/assets/123855860/1/axeDouble_uncommon.gltf.glb"
            },
            "data": {},
            "preload": false,
            "tags": [],
            "i18n": {},
            "id": "123855860"
        },

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the published-build asset registry in config.json and the startup preload path, then compare how templates are separated. Trace where non-preloaded material data is generated and parsed. Done means the published config no longer embeds that full material data and startup avoids parsing it while the asset registry remains usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.