Skip to content

Convert ObjModelParser sample parser to ES6 class#8993

Merged
mvaligursky merged 1 commit into
mainfrom
mv-obj-parser-es6-class
Jun 30, 2026
Merged

Convert ObjModelParser sample parser to ES6 class#8993
mvaligursky merged 1 commit into
mainfrom
mv-obj-parser-es6-class

Conversation

@mvaligursky

Copy link
Copy Markdown
Contributor

Modernize the sample OBJ model parser (scripts/parsers/obj-model.js) from the legacy ES5 constructor-function + Object.assign(prototype, …) pattern to an ES6 class. Behavior is unchanged.

Changes:

  • Convert function ObjModelParser + Object.assign(ObjModelParser.prototype, {…}) into a class ObjModelParser with a constructor and parse / _parseIndices methods.
  • Modernize variable declarations (varconst/let); loop counters and per-branch locals are now block-scoped.
  • Fix a stale usage comment that referenced pc.ObjModelParser (the parser is a bare global, never attached to pc).

Notes:

  • Standalone sample script (not built into the engine library), loaded as a classic <script> by the script asset handler. The loaders/obj example consumes it by bare name (new ObjModelParser(...)), which continues to resolve. The only behavioral difference is that window.ObjModelParser is no longer defined — a class creates a global lexical binding rather than a window property — and nothing in the repo relied on it.

@github-actions

Copy link
Copy Markdown

Build size report

This PR does not change the size of the minified bundles.

Bundle Minified Gzip Brotli
playcanvas.min.js 2270.0 KB — 584.3 KB — 453.7 KB —
playcanvas.min.mjs 2267.4 KB — 583.4 KB — 453.6 KB —

@mvaligursky mvaligursky merged commit 1b82802 into main Jun 30, 2026
10 checks passed
@mvaligursky mvaligursky deleted the mv-obj-parser-es6-class branch June 30, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant