Skip to content

Allow --lod -1 to tag an input as the environment#270

Merged
slimbuck merged 2 commits into
playcanvas:mainfrom
slimbuck:env-dev
Jun 24, 2026
Merged

Allow --lod -1 to tag an input as the environment#270
slimbuck merged 2 commits into
playcanvas:mainfrom
slimbuck:env-dev

Conversation

@slimbuck

Copy link
Copy Markdown
Member

Summary

The environment/skybox concept already exists throughout the pipeline as the sentinel lod === -1 — LCC/LCC2 readers tag environment splats with it, the CLI splits those splats into a separate envDataTable, and the LOD writer emits them to env/meta.json (referenced from lod-meta.json via the environment field). The only gap was that there was no way to assign it manually: --lod validation rejected any negative value, so an arbitrary .ply/.sog/etc. input could never be marked as the environment.

This change relaxes the validation so --lod -1 is accepted, unlocking the existing environment path from the CLI.

Changes

  • Validation (src/cli/index.ts): --lod now rejects values < -1 instead of < 0, permitting the -1 environment sentinel while still rejecting other negatives (only -1 is recognized; other negatives would be mis-binned by the LOD writer).
  • Warning (src/cli/index.ts): environment splats are only written for lod-meta.json output — every other writer ignores envDataTable. We now emit a warning when env-tagged splats are present but the output format isn't LOD, so they aren't silently dropped.
  • Docs: updated the --lod help text and README usage block to (n >= 0, or -1 for environment).
  • Tests (test/cli.test.mjs): added coverage for --lod -1 being accepted and --lod -2 being rejected.

No change was needed to argument tokenization (normalizeArgv already rewrites --lod -1--lod=-1) or to process.ts (it fills the lod column with whatever value, -1 included).

Usage

splat-transform scene.ply --lod 0 env.ply --lod -1 out/lod-meta.json

--lod is per-input, so it must follow the input file it tags. Note that for lod-meta.json output the scene input must itself carry a --lod <n> tag (pre-existing write-lod requirement).

Testing

  • npm run lint — clean
  • node --test test/cli.test.mjs — 4/4 pass; test/write-lod.test.mjs — 2/2 pass
  • End-to-end: scene --lod 0 env --lod -1 out/lod-meta.json writes env/meta.json + textures and sets "environment":"env/meta.json" in the manifest
  • End-to-end: same inputs to out.ply prints the discard warning and excludes the env splats from the output

@slimbuck slimbuck requested a review from Copilot June 24, 2026 11:06
@slimbuck slimbuck self-assigned this Jun 24, 2026
@slimbuck slimbuck added the enhancement New feature or request label Jun 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR closes a CLI gap by allowing users to manually tag an input as the “environment/skybox” using the existing lod === -1 sentinel, matching how LCC/LCC2 inputs are already handled across the pipeline.

Changes:

  • Relax --lod validation to accept -1 (rejecting only values < -1).
  • Emit a warning when environment-tagged splats are present but the output format is not lod-meta.json (since non-LOD writers ignore envDataTable).
  • Update CLI help/README docs and add CLI tests covering --lod -1 acceptance and < -1 rejection.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/cli/index.ts Accepts --lod -1, updates help text, and warns when env-tagged splats will be discarded for non-LOD outputs.
test/cli.test.mjs Adds regression tests for --lod -1 (accepted) and --lod -2 (rejected).
README.md Updates --lod documentation to mention -1 as the environment sentinel.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@slimbuck slimbuck marked this pull request as ready for review June 24, 2026 11:10
@slimbuck slimbuck requested a review from a team June 24, 2026 11:10
@slimbuck slimbuck merged commit 61c1532 into playcanvas:main Jun 24, 2026
3 checks passed
@slimbuck slimbuck deleted the env-dev branch June 24, 2026 11:10
@mvaligursky

Copy link
Copy Markdown
Contributor

why --lod -1 instead of --env or similar?

@slimbuck

Copy link
Copy Markdown
Member Author

it would have to be--lod env, which doesn't really make sense given the rest are --lod 0, --lod 1, --lod 2 etc

@mvaligursky

Copy link
Copy Markdown
Contributor

I'm not why it would have to be --lod env, you're in complete control of this.

@slimbuck

Copy link
Copy Markdown
Member Author

actually using env was my instinct too, but it would mean jumping through a bunch of hoops in the argument parser (this arg is a number). not sure it's worth it? if you really really can't live without it I can probably add an env alias.

@mvaligursky

Copy link
Copy Markdown
Contributor

I don't mind, your call, just pointing it out that it's less clear than ideally should be.

@willeastcott

Copy link
Copy Markdown
Contributor

We can always tweak this in a major version bump. I kinda like the idea of --env. Have a hunch an LLM would understand that better - no 'magic'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants