Skip to content

Add unified grammar engine (RVGG, L-systems, ShapeGrammar), robust lexer/parser, SmartEditor and enhanced WebGL renderer - #2

Open
pghauff73 wants to merge 1 commit into
mainfrom
codex/review-new-commit
Open

Add unified grammar engine (RVGG, L-systems, ShapeGrammar), robust lexer/parser, SmartEditor and enhanced WebGL renderer#2
pghauff73 wants to merge 1 commit into
mainfrom
codex/review-new-commit

Conversation

@pghauff73

Copy link
Copy Markdown
Owner

Motivation

  • Provide a unified, more robust procedural-grammar pipeline for ProGen3d including L-systems, shape grammars and an RVGG (Random Volumetric Geometry Generator) backend to generate richer procedural programs.
  • Improve editor UX and reliability by replacing brittle inline parsing/highlighting with a tolerant lexer/parser, better math evaluation, and an interactive SmartEditor with hover tooltips and wrap sync.
  • Ship a higher-fidelity WebGL renderer and texture pipeline so generated grammars produce correct UVs, mipmapped textures, Blinn-Phong lighting and an STL export path.

Description

  • Added a unified grammar/runtime stack: classes RVGG, ProGen3DGrammar, GrammarLibrary, ShapeGrammar, ProGen3DUnifiedGrammar, GrammarAnalyzer and GrammarVisualizer plus helpers to generate, score and export grammar programs.
  • Reworked the editor and parsing code: introduced a robust GrammarLexer, math evaluator (Solution/MathS2_js), variable management, grammar Grammar/Rule/Token classes, Context/Scope execution model and SmartEditor highlighting/diagnostics (tooltip, wrapping, scroll sync, NL/spacing checks).
  • Improved WebGL scene subsystem: WebGLSceneRenderer now has textured Blinn-Phong shaders, correct cube UVs, procedural texture generators (solid/checker/noise), batching for opaque/transparent draws, camera/orbit controls and an exportSTL implementation.
  • UI and persistence enhancements: randomized grammar generator integration, improved save/load/export flow that persists saved grammars to localStorage (and can download JSON), dropdown chooser population, buttons wired to generation/save/export/open actions, and tutorial/demo loading.

Testing

  • No automated tests were added or executed as part of this change.
  • The changes include runtime-safe guards and defensive parsing to reduce runtime exceptions during editing and generation, and the new renderer and editor were exercised via manual browser smoke runs during development (no CI tests reported).

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 973de5928a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3740 to +3746
const sorted = [...variable_list].sort((a, b) => b.var_name.length - a.var_name.length);

for (let i = 0; i < sorted.length; i++) {
const v = sorted[i];
const name = v.var_name;
const re = new RegExp(`\\b${escRe(name)}\\b`, "g");
s = s.replace(re, String(v.value));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve scope precedence in variable substitution

replacevars now sorts variable_list by name length before substitution, which loses the stack-like scoping order for duplicate names. When a rule introduces a shadowed variable (via addVariableInstance), the older outer variable is substituted first and the newer in-scope value is never applied, so expressions like repeat counts/transforms can evaluate with stale values in recursive or nested rule execution. This is a regression from the previous reverse traversal that preferred the most recent binding.

Useful? React with 👍 / 👎.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant