pelican-engine 0.0.0-stage → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +147 -0
- package/LICENSE +22 -0
- package/README.md +129 -2
- package/distribution.json +197 -0
- package/docs/AI-WORKFLOW.md +517 -0
- package/docs/ARCHITECTURE.md +268 -0
- package/docs/CAPABILITIES.md +264 -0
- package/docs/DECISIONS.md +107 -0
- package/docs/M3-USAGE.md +192 -0
- package/docs/PELICAN-MIGRATION.md +38 -0
- package/docs/RENDER-BACKENDS.md +50 -0
- package/docs/ROADMAP.md +239 -0
- package/docs/THIRD-PARTY-NOTICES.md +151 -0
- package/docs/api/REFERENCE.md +1435 -0
- package/docs/api/index.json +1139 -0
- package/docs/npm/DISTRIBUTION.md +130 -0
- package/docs/npm/GAME-AUTHOR.md +147 -0
- package/engine.manifest.json +15 -0
- package/lib/assets/audio.js +67 -0
- package/lib/assets/errors.js +36 -0
- package/lib/assets/glb.js +277 -0
- package/lib/assets/index.js +53 -0
- package/lib/assets/jpeg.js +199 -0
- package/lib/assets/model.js +558 -0
- package/lib/assets/optimize.js +95 -0
- package/lib/assets/texture.js +187 -0
- package/lib/compiler/distribution.js +17 -0
- package/lib/compiler/extract.js +425 -0
- package/lib/compiler/graph.js +366 -0
- package/lib/compiler/index.js +574 -0
- package/lib/compiler/normalize.js +1194 -0
- package/lib/compiler/source-map.js +25 -0
- package/lib/compiler/types.js +2 -0
- package/lib/compiler/version.js +93 -0
- package/lib/experiments/simulation/index.js +2 -0
- package/lib/experiments/simulation/math.js +41 -0
- package/lib/experiments/simulation/probe.js +215 -0
- package/lib/experiments/simulation/scenes.js +192 -0
- package/lib/experiments/simulation/solver.js +346 -0
- package/lib/experiments/simulation/types.js +1 -0
- package/lib/experiments/world/adapters.js +30 -0
- package/lib/experiments/world/geometry.js +180 -0
- package/lib/experiments/world/index.js +2 -0
- package/lib/experiments/world/probe.js +288 -0
- package/lib/experiments/world/types.js +1 -0
- package/lib/experiments/world/world.js +599 -0
- package/lib/navigation/index.js +157 -0
- package/lib/physics/index.js +909 -0
- package/lib/protocol/index.js +92 -0
- package/lib/renderer/acceleration.js +609 -0
- package/lib/renderer/browser.js +2015 -0
- package/lib/renderer/bsdf.js +260 -0
- package/lib/renderer/checkpoint.js +88 -0
- package/lib/renderer/compute-executor.js +1034 -0
- package/lib/renderer/compute-texture-assets.js +49 -0
- package/lib/renderer/compute-view-contract.js +1 -0
- package/lib/renderer/denoiser.js +361 -0
- package/lib/renderer/dielectric.js +360 -0
- package/lib/renderer/embedded-image-pixels.js +368 -0
- package/lib/renderer/emissive-lights.js +67 -0
- package/lib/renderer/environment-importance.js +55 -0
- package/lib/renderer/environment.js +346 -0
- package/lib/renderer/gameplay.js +464 -0
- package/lib/renderer/geometry.js +103 -0
- package/lib/renderer/graph-expressions.js +485 -0
- package/lib/renderer/graph-tsl.js +141 -0
- package/lib/renderer/graph.js +214 -0
- package/lib/renderer/managed-texture-sampling.js +29 -0
- package/lib/renderer/material-graphs.js +297 -0
- package/lib/renderer/medium.js +348 -0
- package/lib/renderer/models.js +1053 -0
- package/lib/renderer/motion-shader.js +40 -0
- package/lib/renderer/path-shader.js +196 -0
- package/lib/renderer/pathtrace.js +324 -0
- package/lib/renderer/postprocess-contract.js +1 -0
- package/lib/renderer/postprocess.js +494 -0
- package/lib/renderer/render-buffers.js +132 -0
- package/lib/renderer/render-textures.js +155 -0
- package/lib/renderer/startup.js +50 -0
- package/lib/renderer/surface-capture.js +199 -0
- package/lib/renderer/surface-gpu.js +270 -0
- package/lib/renderer/surface-motion.js +84 -0
- package/lib/renderer/surface-ray-shader.js +91 -0
- package/lib/renderer/surface-shader.js +88 -0
- package/lib/renderer/surface-tracer.js +1720 -0
- package/lib/renderer/surface.js +1425 -0
- package/lib/renderer/temporal-filter.js +512 -0
- package/lib/renderer/texture-pixels.js +207 -0
- package/lib/renderer/traversal-nodes.js +54 -0
- package/lib/renderer/ui.js +446 -0
- package/lib/renderer/vertex-bounds.js +127 -0
- package/lib/renderer/vertex-contract.js +1 -0
- package/lib/renderer/vertex-graphs.js +197 -0
- package/lib/renderer/volume-shader.js +50 -0
- package/lib/runtime/compute-contract.js +1 -0
- package/lib/runtime/compute-service.js +674 -0
- package/lib/runtime/contracts.js +1 -0
- package/lib/runtime/error.js +37 -0
- package/lib/runtime/events.js +189 -0
- package/lib/runtime/game-services.js +772 -0
- package/lib/runtime/host.js +839 -0
- package/lib/runtime/material-parameters.js +145 -0
- package/lib/runtime/plugins.js +1 -0
- package/lib/runtime/postprocess-contract.js +1 -0
- package/lib/runtime/postprocess.js +189 -0
- package/lib/runtime/prefabs.js +13 -0
- package/lib/runtime/random.js +88 -0
- package/lib/runtime/render-buffer-contract.js +1 -0
- package/lib/runtime/render-buffers.js +243 -0
- package/lib/runtime/render-capabilities.js +17 -0
- package/lib/runtime/render-settings.js +249 -0
- package/lib/runtime/render-texture-contract.js +1 -0
- package/lib/runtime/render-textures.js +271 -0
- package/lib/runtime/resources.js +648 -0
- package/lib/runtime/scheduler.js +765 -0
- package/lib/runtime/storage.js +169 -0
- package/lib/runtime/world.js +594 -0
- package/lib/schema/index.js +24 -0
- package/lib/sdk/graph-values.js +16 -0
- package/lib/sdk/index.d.ts +800 -0
- package/lib/sdk/index.js +82 -0
- package/lib/tools/api-index.js +113 -0
- package/lib/tools/browser-session.js +89 -0
- package/lib/tools/cli.js +513 -0
- package/lib/tools/compress-dist.js +59 -0
- package/lib/tools/control-client.js +153 -0
- package/lib/tools/control-server.js +633 -0
- package/lib/tools/diagnostic-code.js +3 -0
- package/lib/tools/doctor.js +496 -0
- package/lib/tools/npm/browser-cli.js +6 -0
- package/lib/tools/npm/entry.js +40 -0
- package/lib/tools/npm/layout.js +195 -0
- package/lib/tools/setup.js +153 -0
- package/licenses/@dimforge/rapier2d-compat/LICENSE +201 -0
- package/licenses/@dimforge/rapier3d-compat/LICENSE +201 -0
- package/licenses/@gltf-transform/core/LICENSE.md +21 -0
- package/licenses/@gltf-transform/extensions/LICENSE.md +21 -0
- package/licenses/@gltf-transform/functions/LICENSE.md +21 -0
- package/licenses/@img/colour/LICENSE.md +82 -0
- package/licenses/@img/sharp-win32-x64/LICENSE +191 -0
- package/licenses/@oxc-project/types/LICENSE +22 -0
- package/licenses/@rolldown/pluginutils/LICENSE +21 -0
- package/licenses/@tweenjs/tween.js/LICENSE +23 -0
- package/licenses/@types/ndarray/LICENSE +21 -0
- package/licenses/@types/node/LICENSE +21 -0
- package/licenses/@types/stats.js/LICENSE +21 -0
- package/licenses/@types/three/@dimforge/rapier3d-compat/LICENSE +201 -0
- package/licenses/@types/three/LICENSE +21 -0
- package/licenses/@types/webxr/LICENSE +21 -0
- package/licenses/@webgpu/types/LICENSE +26 -0
- package/licenses/THIRD-PARTY-NOTICES.md +139 -0
- package/licenses/cwise-compiler/LICENSE +22 -0
- package/licenses/detect-libc/LICENSE +201 -0
- package/licenses/esbuild/LICENSE.md +21 -0
- package/licenses/fast-png/LICENSE +21 -0
- package/licenses/fdir/LICENSE +7 -0
- package/licenses/fflate/LICENSE +21 -0
- package/licenses/iobuffer/LICENSE +22 -0
- package/licenses/iota-array/LICENSE +22 -0
- package/licenses/is-buffer/LICENSE +21 -0
- package/licenses/ktx-parse/LICENSE +21 -0
- package/licenses/lightningcss/LICENSE +373 -0
- package/licenses/lightningcss-win32-x64-msvc/LICENSE +373 -0
- package/licenses/meshoptimizer/LICENSE.md +21 -0
- package/licenses/nanoid/LICENSE +20 -0
- package/licenses/ndarray/LICENSE +22 -0
- package/licenses/ndarray-lanczos/LICENSE +21 -0
- package/licenses/ndarray-ops/LICENSE +22 -0
- package/licenses/ndarray-pixels/LICENSE +21 -0
- package/licenses/ngraph.path/LICENSE +21 -0
- package/licenses/picocolors/LICENSE +15 -0
- package/licenses/picomatch/LICENSE +21 -0
- package/licenses/playwright/LICENSE +202 -0
- package/licenses/playwright/NOTICE +5 -0
- package/licenses/playwright-core/LICENSE +202 -0
- package/licenses/playwright-core/NOTICE +5 -0
- package/licenses/postcss/LICENSE +20 -0
- package/licenses/prettier/LICENSE +7 -0
- package/licenses/property-graph/LICENSE +21 -0
- package/licenses/rolldown/LICENSE +25 -0
- package/licenses/semver/LICENSE +15 -0
- package/licenses/sharp/LICENSE +191 -0
- package/licenses/source-map-js/LICENSE +28 -0
- package/licenses/three/LICENSE +21 -0
- package/licenses/tinyglobby/LICENSE +21 -0
- package/licenses/tsx/LICENSE +21 -0
- package/licenses/typescript/LICENSE.txt +55 -0
- package/licenses/undici-types/LICENSE +21 -0
- package/licenses/uniq/LICENSE +22 -0
- package/licenses/vite/LICENSE.md +2084 -0
- package/package.json +49 -4
- package/web/index.html +34 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
export function fail(code, message) {
|
|
2
|
+
throw new Error(`TC_WORLD_${code}: ${message}`);
|
|
3
|
+
}
|
|
4
|
+
export function record(value, label) {
|
|
5
|
+
if (value === null ||
|
|
6
|
+
typeof value !== "object" ||
|
|
7
|
+
Array.isArray(value) ||
|
|
8
|
+
(Object.getPrototypeOf(value) !== Object.prototype &&
|
|
9
|
+
Object.getPrototypeOf(value) !== null)) {
|
|
10
|
+
fail("SCHEMA", `${label} must be a plain record.`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function identifier(value, label) {
|
|
14
|
+
if (typeof value !== "string" || value.trim().length === 0)
|
|
15
|
+
fail("ID", `${label} must be a nonempty string.`);
|
|
16
|
+
}
|
|
17
|
+
function fieldValue(field, value, label) {
|
|
18
|
+
switch (field.type) {
|
|
19
|
+
case "number":
|
|
20
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
21
|
+
fail("VALUE", `${label} must be finite.`);
|
|
22
|
+
return value;
|
|
23
|
+
case "boolean":
|
|
24
|
+
if (typeof value !== "boolean")
|
|
25
|
+
fail("VALUE", `${label} must be boolean.`);
|
|
26
|
+
return value;
|
|
27
|
+
case "string":
|
|
28
|
+
if (typeof value !== "string")
|
|
29
|
+
fail("VALUE", `${label} must be string.`);
|
|
30
|
+
return value;
|
|
31
|
+
case "vec3":
|
|
32
|
+
if (!Array.isArray(value) ||
|
|
33
|
+
value.length !== 3 ||
|
|
34
|
+
![0, 1, 2].every((i) => typeof value[i] === "number" && Number.isFinite(value[i]))) {
|
|
35
|
+
fail("VALUE", `${label} must contain exactly three finite numbers.`);
|
|
36
|
+
}
|
|
37
|
+
return [value[0], value[1], value[2]];
|
|
38
|
+
default:
|
|
39
|
+
return fail("SCHEMA", `${label} has an unsupported field type.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function cloneSchema(input) {
|
|
43
|
+
record(input, "Component schema");
|
|
44
|
+
return Object.fromEntries(Object.entries(input).map(([name, entry]) => {
|
|
45
|
+
identifier(name, "Field name");
|
|
46
|
+
record(entry, `Field ${name}`);
|
|
47
|
+
if (!Object.hasOwn(entry, "type") ||
|
|
48
|
+
!Object.hasOwn(entry, "default") ||
|
|
49
|
+
Object.keys(entry).some((key) => key !== "type" && key !== "default")) {
|
|
50
|
+
fail("SCHEMA", `Field ${name} requires only type and default.`);
|
|
51
|
+
}
|
|
52
|
+
const field = entry;
|
|
53
|
+
return [
|
|
54
|
+
name,
|
|
55
|
+
{
|
|
56
|
+
type: field.type,
|
|
57
|
+
default: fieldValue(field, field.default, `Default ${name}`),
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
/** full=false validates a patch; full=true adds defaults (or requires complete snapshot data). */
|
|
63
|
+
export function values(schema, input, full, strict = false) {
|
|
64
|
+
record(input, "Component data");
|
|
65
|
+
const entries = [];
|
|
66
|
+
for (const key of Object.keys(input)) {
|
|
67
|
+
if (!Object.hasOwn(schema, key))
|
|
68
|
+
fail("FIELD", `Unknown component field ${key}.`);
|
|
69
|
+
}
|
|
70
|
+
for (const [key, field] of Object.entries(schema)) {
|
|
71
|
+
if (Object.hasOwn(input, key))
|
|
72
|
+
entries.push([key, fieldValue(field, input[key], key)]);
|
|
73
|
+
else if (strict)
|
|
74
|
+
fail("FIELD", `Snapshot is missing field ${key}.`);
|
|
75
|
+
else if (full)
|
|
76
|
+
entries.push([key, fieldValue(field, field.default, key)]);
|
|
77
|
+
}
|
|
78
|
+
return Object.fromEntries(entries);
|
|
79
|
+
}
|
|
80
|
+
/** Private storage module; presence and every field are indexed by stable entity index. */
|
|
81
|
+
export class ComponentStorage {
|
|
82
|
+
schema;
|
|
83
|
+
columns = new Map();
|
|
84
|
+
presence;
|
|
85
|
+
constructor(schema, capacity) {
|
|
86
|
+
this.schema = cloneSchema(schema);
|
|
87
|
+
this.presence = new Uint8Array(capacity);
|
|
88
|
+
for (const [key, field] of Object.entries(this.schema)) {
|
|
89
|
+
this.columns.set(key, field.type === "string"
|
|
90
|
+
? new Array(capacity).fill("")
|
|
91
|
+
: field.type === "boolean"
|
|
92
|
+
? new Uint8Array(capacity)
|
|
93
|
+
: new Float64Array(capacity * (field.type === "vec3" ? 3 : 1)));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
grow(capacity) {
|
|
97
|
+
if (capacity <= this.presence.length)
|
|
98
|
+
return;
|
|
99
|
+
const presence = new Uint8Array(capacity);
|
|
100
|
+
presence.set(this.presence);
|
|
101
|
+
this.presence = presence;
|
|
102
|
+
for (const [key, field] of Object.entries(this.schema)) {
|
|
103
|
+
const previous = this.columns.get(key);
|
|
104
|
+
if (Array.isArray(previous)) {
|
|
105
|
+
this.columns.set(key, [
|
|
106
|
+
...previous,
|
|
107
|
+
...new Array(capacity - previous.length).fill(""),
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const column = field.type === "boolean"
|
|
112
|
+
? new Uint8Array(capacity)
|
|
113
|
+
: new Float64Array(capacity * (field.type === "vec3" ? 3 : 1));
|
|
114
|
+
column.set(previous);
|
|
115
|
+
this.columns.set(key, column);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
write(index, data) {
|
|
120
|
+
for (const [key, value] of Object.entries(data)) {
|
|
121
|
+
const column = this.columns.get(key);
|
|
122
|
+
switch (this.schema[key].type) {
|
|
123
|
+
case "vec3":
|
|
124
|
+
column.set(value, index * 3);
|
|
125
|
+
break;
|
|
126
|
+
case "boolean":
|
|
127
|
+
column[index] = value ? 1 : 0;
|
|
128
|
+
break;
|
|
129
|
+
case "number":
|
|
130
|
+
column[index] = value;
|
|
131
|
+
break;
|
|
132
|
+
case "string":
|
|
133
|
+
column[index] = value;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
this.presence[index] = 1;
|
|
138
|
+
}
|
|
139
|
+
read(index) {
|
|
140
|
+
return Object.fromEntries(Object.entries(this.schema).map(([key, field]) => {
|
|
141
|
+
const column = this.columns.get(key);
|
|
142
|
+
const value = field.type === "vec3"
|
|
143
|
+
? Array.from(column.subarray(index * 3, index * 3 + 3))
|
|
144
|
+
: field.type === "boolean"
|
|
145
|
+
? Boolean(column[index])
|
|
146
|
+
: column[index];
|
|
147
|
+
return [key, value];
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
remove(index) {
|
|
151
|
+
this.presence[index] = 0;
|
|
152
|
+
for (const [key, field] of Object.entries(this.schema)) {
|
|
153
|
+
const column = this.columns.get(key);
|
|
154
|
+
if (field.type === "vec3")
|
|
155
|
+
column.fill(0, index * 3, index * 3 + 3);
|
|
156
|
+
else if (field.type === "string")
|
|
157
|
+
column[index] = "";
|
|
158
|
+
else
|
|
159
|
+
column[index] = 0;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
clone() {
|
|
163
|
+
const result = new ComponentStorage(this.schema, this.presence.length);
|
|
164
|
+
result.presence.set(this.presence);
|
|
165
|
+
for (const [key, column] of this.columns)
|
|
166
|
+
result.columns.set(key, column.slice());
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
}
|