# Dimentra3D Android Preview

This is a **standalone Android source prototype** for previewing a bounded
Dimentra3D scene on a phone. It packages the same JavaScript parser,
Dimentra3D-to-scene lowering and CPU reference rasterizer used by the desktop
tests in a local-only WebView. It is not part of the N8128 emulator app, does
not use its emulator renderer, and does not execute Dimentra3D effects.

The prototype renders the icospheres, opaque base colors, roughness/metallic/
clearcoat/emission values, declared light colors/intensities, and orthographic
orbit camera from `examples/scene.dimentra`. `dimentra3d-render.js` rejects
mesh generators and camera modes outside its subset. The Android view is
limited to 400x300 pixels; this is a correctness/interaction prototype, not a
mobile performance claim or native GPU renderer.

## DimentraBuild: build without Gradle

The custom `build.ps1` is the first app-specific **DimentraBuild** task. It
assembles an APK directly with Android platform tools instead of delegating
this prototype to Gradle. This is not yet a general build system for every
Android project, and it does not eliminate the Android SDK or Java compiler.
It still requires:

- JDK 17 or newer (`JAVA_HOME`);
- Android SDK Platform 35 or newer;
- Android SDK Build-Tools 35 or newer;
- `ANDROID_SDK_ROOT` (or `ANDROID_HOME`) pointing to that SDK.

From the repository root in PowerShell:

```powershell
$env:JAVA_HOME = 'C:\Path\To\JDK'
$env:ANDROID_SDK_ROOT = 'C:\Path\To\Android\Sdk'
npm.cmd run build:dimentra3d-android
```

The script calls `aapt2`, `javac`, `d8`, `jar`, `zipalign`, `keytool` and
`apksigner` directly. It validates exit codes and verifies the signed APK.
The debug APK and its local debug keystore are written under this ignored
directory:

```text
workshop/dimentra3d/android/build/Dimentra3DPreview-debug.apk
```

The prototype key is local test material, not a release signing identity. Do
not publish the generated key or use it for production distribution. A release
app would need a separate, user-controlled signing setup.

If `adb` is installed and a device is connected, install with:

```powershell
adb install -r .\workshop\dimentra3d\android\build\Dimentra3DPreview-debug.apk
```

## Isolation

The APK has no Internet permission. Its WebView loads one packaged page and
the explicitly packaged parser/geometry/renderer JavaScript files. It has no
JavaScript interface to Android, blocks non-packaged requests and navigation,
disables universal/file-URL cross-access, content access, popups and mixed
content, and releases the WebView when its activity is destroyed. Do not add a
native bridge, remote content, asset-path loading or effect execution without
a separate threat model and review.

The scene editor in this prototype is a local text area with a bounded source
size. Source is displayed/diagnosed as text and parsed by the real
Dimentra3D parser. The renderer compiles only the explicit preview subset to
versioned in-memory Scene IR and uses the existing CPU rasterizer. Unsupported
input clears the canvas and reports an error instead of showing an old frame.

## Verification status

The renderer's Node conformance tests exercise scene lowering, the actual
pixel buffer, deterministic redraw, resource bounds, unsupported generators
and parity between the sample in this page and `examples/scene.dimentra`.
The APK itself still needs to be built and installed with the Android toolchain
above. Verify on a device/emulator after building; a successful JavaScript
test is not Android installation or lifecycle evidence.
