feat: add MyFirstScene minimal example
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sun, 15 Mar 2026 22:25:28 +0000 (00:25 +0200)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sun, 15 Mar 2026 22:25:28 +0000 (00:25 +0200)
- Add MyFirstScene.java as runnable minimal example from docs

- Add My First Scene button to demo launcher

- Fix duplicate org-mode ID in mathematical formulas section

doc/index.org
src/main/java/eu/svjatoslav/sixth/e3d/examples/MyFirstScene.java [new file with mode: 0644]
src/main/java/eu/svjatoslav/sixth/e3d/examples/launcher/ApplicationListPanel.java

index 7301d42..f76fea1 100644 (file)
@@ -156,7 +156,7 @@ See also [[https://hackers-1995.vercel.app/][similar looking web based demo]] !
 ** Mathematical formulas
 :PROPERTIES:
 :CUSTOM_ID: mathematical-formulas
-:ID:       a1b2c3d4-e5f6-7890-abcd-ef1234567890
+:ID:       b1c2d3e4-f5a6-7890-bcde-f12345678901
 :END:
 
 [[file:Screenshots/Mathematical formulas.png]]
@@ -239,7 +239,6 @@ Star Grid                    256.88
 ================================================================================
 #+end_example
 
-
 ** Developer tools
 :PROPERTIES:
 :CUSTOM_ID: developer-tools
diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/MyFirstScene.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/MyFirstScene.java
new file mode 100644 (file)
index 0000000..ffef135
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Sixth 3D engine demos. Author: Svjatoslav Agejenko.
+ * This project is released under Creative Commons Zero (CC0) license.
+ *
+ */
+package eu.svjatoslav.sixth.e3d.examples;
+
+import eu.svjatoslav.sixth.e3d.geometry.Point3D;
+import eu.svjatoslav.sixth.e3d.gui.ViewFrame;
+import eu.svjatoslav.sixth.e3d.math.Transform;
+import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
+import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection;
+import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.solid.SolidPolygonRectangularBox;
+
+/**
+ * Minimal example demonstrating how to create a basic 3D scene.
+ * <p>
+ * Creates a window with a single red box. This is the "Create Your First 3D Scene"
+ * example from the Sixth 3D documentation.
+ */
+public class MyFirstScene {
+
+    /**
+     * Entry point for the minimal scene demo.
+     * @param args command line arguments (ignored)
+     */
+    public static void main(String[] args) {
+        ViewFrame viewFrame = new ViewFrame();
+        ShapeCollection shapes = viewFrame.getViewPanel().getRootShapeCollection();
+
+        Transform boxTransform = new Transform(new Point3D(0, 0, 0), 0, 0);
+        SolidPolygonRectangularBox box = new SolidPolygonRectangularBox(
+                new Point3D(-50, -50, -50),
+                new Point3D(50, 50, 50),
+                Color.RED
+        );
+        box.setTransform(boxTransform);
+        shapes.addShape(box);
+
+        viewFrame.getViewPanel().getCamera().getTransform().setTranslation(new Point3D(0, -100, -300));
+
+        viewFrame.getViewPanel().ensureRenderThreadStarted();
+    }
+}
\ No newline at end of file
index ea856e6..3344454 100644 (file)
@@ -7,6 +7,7 @@
 package eu.svjatoslav.sixth.e3d.examples.launcher;
 
 import eu.svjatoslav.sixth.e3d.examples.GraphDemo;
+import eu.svjatoslav.sixth.e3d.examples.MyFirstScene;
 import eu.svjatoslav.sixth.e3d.examples.OctreeDemo;
 import eu.svjatoslav.sixth.e3d.examples.RandomPolygonsDemo;
 import eu.svjatoslav.sixth.e3d.examples.RainingNumbersDemo;
@@ -31,6 +32,7 @@ class ApplicationListPanel extends JPanel {
         final GroupLayout groupLayout = new GroupLayout(this);
         GroupLayout.SequentialGroup sequentialGroup = groupLayout.createSequentialGroup();
         sequentialGroup.addComponent(new JLabel("Choose an example to launch:"));
+        sequentialGroup.addComponent(new JButton(new ShowMyFirstScene()));
         sequentialGroup.addComponent(new JButton(new ShowOctree()));
         sequentialGroup.addComponent(new JButton(new ShowMathGraphs()));
         sequentialGroup.addComponent(new JButton(new ShowPointCloud()));
@@ -43,6 +45,18 @@ class ApplicationListPanel extends JPanel {
         sequentialGroup.addComponent(new JButton(new ShowGraphicsBenchmark()));
     }
 
+    /** Action to launch the MyFirstScene (minimal example). */
+    private static class ShowMyFirstScene extends AbstractAction {
+        ShowMyFirstScene() {
+            putValue(NAME, "My First Scene");
+        }
+
+        @Override
+        public void actionPerformed(final ActionEvent e) {
+            MyFirstScene.main(null);
+        }
+    }
+
     /** Action to launch the TextEditorDemo. */
     private static class ShowTextEditors extends AbstractAction {
         ShowTextEditors() {