playcanvas / playcanvas/engine

Consider optional area-light LUT data export when UMD bundle size is less important

Open
#9,324 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

Area-light examples currently load examples/assets/json/area-light-luts.json as a JSON asset and pass its two arrays to app.setAreaLightLuts(). Providing this data as an optional engine export would remove the need for applications to copy and load a separate asset.

Consider adding a side-effect-free JavaScript data module under src/extras/, exporting the existing LUT arrays. A JavaScript module fits the current build pipeline without adding JSON module support. Applications would explicitly import the data and pass it to the existing setter; retain support for externally loaded LUTs.

Proposed usage (API name to be decided):

import { areaLightLutData } from 'playcanvas';

app.setAreaLightLuts(
    areaLightLutData.LTC_MAT_1,
    areaLightLutData.LTC_MAT_2
);

Unused data can be tree-shaken by consumer ESM bundlers, provided the engine does not import it automatically through AppBase or other core initialization paths.

Deferred due to bundle size

Re-exporting the data through the main engine entry point would also include it in the prebuilt UMD and full ESM bundles. The current JSON is approximately 300 KiB raw / 103 KiB gzipped; the exact bundle increase would depend on its JavaScript representation and compression.

Leave this for later and revisit when UMD distribution is less important. At that point, assess the bundle impact and whether a separate package entry point is preferable, update the area-light examples, and verify that consumer bundles exclude unused LUT data.

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 with examples/assets/json/area-light-luts.json, the area-light examples, and the existing app.setAreaLightLuts() path. Review how modules under src/extras/ are exposed without being imported through AppBase, then assess the JavaScript representation and UMD/full ESM bundle impact. Done means choosing the export or package entry point, updating the examples, retaining external LUT support, and verifying unused data can be excluded by consumer ESM bundlers.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.