Enhance CDN packages and playground

Amp-Thread-ID: https://ampcode.com/threads/T-01a02485-5574-707c-bff4-5668d83bee8a
Co-authored-by: Heaust Azure <heaust.azure@gmail.com>
This commit is contained in:
Amp
2026-08-22 06:21:39 +00:00
co-authored by heaust
parent 7070799862
commit d95e099fa4
17 changed files with 1870 additions and 247 deletions
+31
View File
@@ -0,0 +1,31 @@
import { Mesh, type MeshOptions } from "../Mesh";
import type { Scene } from "../Scene";
export type PlaneOptions = Omit<MeshOptions, "geometryId" | "vertexData"> & {
size?: number;
width?: number;
depth?: number;
};
function dimension(value: number, name: string) {
if (!Number.isFinite(value) || value <= 0) throw new RangeError(name);
return value / 2;
}
/** A horizontal, upward-facing plane centered on its transform. */
export class Plane extends Mesh {
constructor(scene: Scene, options: PlaneOptions = {}) {
const { size = 1, width = size, depth = size, ...meshOptions } = options;
const x = dimension(width, "width");
const z = dimension(depth, "depth");
super(scene, {
...meshOptions,
vertexData: {
positions: [-x, 0, -z, x, 0, -z, x, 0, z, -x, 0, z],
normals: [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0],
uvs: [0, 0, 1, 0, 1, 1, 0, 1],
indices: [0, 2, 1, 0, 3, 2],
},
});
}
}