@kite3d/engine 0.15.0
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/dist/authoring.d.ts +54 -0
- package/dist/authoring.js +165 -0
- package/dist/authoring.js.map +1 -0
- package/dist/authoringValidation.d.ts +110 -0
- package/dist/authoringValidation.js +488 -0
- package/dist/authoringValidation.js.map +1 -0
- package/dist/defaults.d.ts +2 -0
- package/dist/fileTypes.d.ts +5 -0
- package/dist/fileTypes.js +51 -0
- package/dist/fileTypes.js.map +1 -0
- package/dist/importMap.d.ts +15 -0
- package/dist/importMap.js +62 -0
- package/dist/importMap.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +2756 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations.js +5 -0
- package/dist/migrations.js.map +1 -0
- package/dist/paths.d.ts +9 -0
- package/dist/paths.js +13 -0
- package/dist/paths.js.map +1 -0
- package/dist/plugins/GeneratorComponent.d.ts +40 -0
- package/dist/plugins/HtmlUiComponent.d.ts +52 -0
- package/dist/plugins/HtmlUiComponent.example.d.ts +0 -0
- package/dist/plugins/cannon/Cannon3DBodyComponent.d.ts +27 -0
- package/dist/plugins/cannon/Cannon3DShapeComponent.d.ts +57 -0
- package/dist/plugins/cannon/CannonPhysicsPlugin.d.ts +63 -0
- package/dist/plugins/cannon/CannonRagdollComponent.d.ts +148 -0
- package/dist/plugins/cannon/helper.d.ts +24 -0
- package/dist/plugins/cannon/threeToCannon.d.ts +63 -0
- package/dist/plugins/cannon/utils.d.ts +9 -0
- package/dist/projectFormat.js +108 -0
- package/dist/projectFormat.js.map +1 -0
- package/dist/runtime/createGame.d.ts +29 -0
- package/dist/runtime/index.d.ts +18 -0
- package/dist/runtime/migrations.d.ts +5 -0
- package/dist/runtime/nestedAssets.d.ts +26 -0
- package/dist/runtime/projectFormat.d.ts +83 -0
- package/dist/runtime/version.d.ts +1 -0
- package/dist/runtime.js +72835 -0
- package/dist/runtime.js.map +1 -0
- package/dist/sceneSerialization.d.ts +17 -0
- package/dist/sceneSerialization.js +174 -0
- package/dist/sceneSerialization.js.map +1 -0
- package/dist/scripts.d.ts +17 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/package.json +86 -0
- package/src/authoring.ts +293 -0
- package/src/authoringValidation.ts +815 -0
- package/src/defaults.ts +277 -0
- package/src/fileTypes.ts +53 -0
- package/src/importMap.ts +105 -0
- package/src/index.ts +15 -0
- package/src/paths.ts +9 -0
- package/src/plugins/GeneratorComponent.ts +275 -0
- package/src/plugins/HtmlUiComponent.example.ts +202 -0
- package/src/plugins/HtmlUiComponent.md +219 -0
- package/src/plugins/HtmlUiComponent.ts +320 -0
- package/src/plugins/cannon/Cannon3DBodyComponent.ts +227 -0
- package/src/plugins/cannon/Cannon3DShapeComponent.ts +258 -0
- package/src/plugins/cannon/CannonPhysicsPlugin.ts +409 -0
- package/src/plugins/cannon/CannonRagdollComponent.ts +1170 -0
- package/src/plugins/cannon/helper.ts +255 -0
- package/src/plugins/cannon/threeToCannon.ts +441 -0
- package/src/plugins/cannon/utils.ts +185 -0
- package/src/runtime/createGame.ts +337 -0
- package/src/runtime/index.ts +19 -0
- package/src/runtime/migrations.ts +6 -0
- package/src/runtime/nestedAssets.ts +226 -0
- package/src/runtime/projectFormat.ts +233 -0
- package/src/runtime/version.ts +3 -0
- package/src/sceneSerialization.ts +289 -0
- package/src/scripts.ts +52 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { IObject3D } from 'threepipe';
|
|
2
|
+
export declare const KITE3D_AUTHORING_METADATA_KEY = "kite3dAuthoring";
|
|
3
|
+
export declare const KITE3D_RUNTIME_METADATA_KEY = "kite3dRuntime";
|
|
4
|
+
export type AuthoringRole = 'direct' | 'template' | 'generator';
|
|
5
|
+
export interface AuthoringMetadata {
|
|
6
|
+
role: AuthoringRole;
|
|
7
|
+
id: string;
|
|
8
|
+
sourceId?: string;
|
|
9
|
+
allowCameraInside?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface RuntimeObjectMetadata {
|
|
12
|
+
ownerId: string;
|
|
13
|
+
kind: 'clone' | 'effect';
|
|
14
|
+
sourceId: string;
|
|
15
|
+
overrides?: RuntimeMutableProperty[];
|
|
16
|
+
}
|
|
17
|
+
export type RuntimeMutableProperty = 'position' | 'rotation' | 'scale' | 'visible' | 'material';
|
|
18
|
+
export interface RuntimeCloneOptions {
|
|
19
|
+
name?: string;
|
|
20
|
+
visible?: boolean;
|
|
21
|
+
position?: [number, number, number];
|
|
22
|
+
rotation?: [number, number, number];
|
|
23
|
+
scale?: [number, number, number];
|
|
24
|
+
runtimeMutable?: RuntimeMutableProperty[];
|
|
25
|
+
}
|
|
26
|
+
export interface RuntimeScene extends IObject3D {
|
|
27
|
+
modelRoot: IObject3D;
|
|
28
|
+
}
|
|
29
|
+
/** Store a validated, serializable authored identity on an object. */
|
|
30
|
+
export declare function setAuthoringMetadata(object: IObject3D, metadata: AuthoringMetadata): AuthoringMetadata;
|
|
31
|
+
/** Read authoring metadata without trusting arbitrary userData. */
|
|
32
|
+
export declare function getAuthoringMetadata(object: IObject3D): AuthoringMetadata | undefined;
|
|
33
|
+
export declare function getRuntimeObjectMetadata(object: IObject3D): RuntimeObjectMetadata | undefined;
|
|
34
|
+
export declare function isRuntimeObject(object: IObject3D): boolean;
|
|
35
|
+
/** Return the live objects tracked against one viewer scene. */
|
|
36
|
+
export declare function getTrackedRuntimeObjects(scene: IObject3D): readonly IObject3D[];
|
|
37
|
+
/**
|
|
38
|
+
* Owns Play-only roots and clones. A single owner should be created in start()
|
|
39
|
+
* and cleaned in stop(); cleanup is idempotent.
|
|
40
|
+
*/
|
|
41
|
+
export declare class RuntimeObjectOwner {
|
|
42
|
+
readonly ownerId: string;
|
|
43
|
+
private readonly objects;
|
|
44
|
+
private readonly protectedResources;
|
|
45
|
+
private runtimeParent?;
|
|
46
|
+
private nextObject;
|
|
47
|
+
constructor(ownerId: string);
|
|
48
|
+
attachRuntimeRoot<T extends IObject3D>(root: T, scene: RuntimeScene, authoredOwner: IObject3D): T;
|
|
49
|
+
trackEffect<T extends IObject3D>(root: T, owner: IObject3D): T;
|
|
50
|
+
cloneFrom<T extends IObject3D>(source: T, parent?: IObject3D | undefined, options?: RuntimeCloneOptions): T;
|
|
51
|
+
cleanup(): void;
|
|
52
|
+
private track;
|
|
53
|
+
private markRuntimeObject;
|
|
54
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
const l = "kite3dAuthoring", h = "kite3dRuntime", g = /* @__PURE__ */ new Set(["direct", "template", "generator"]), d = /* @__PURE__ */ new Map();
|
|
2
|
+
function O(r, e) {
|
|
3
|
+
var i;
|
|
4
|
+
const t = A(e);
|
|
5
|
+
return r.userData[l] = t, (i = r.setDirty) == null || i.call(r, { source: "Kite3D authoring", change: `userData.${l}` }), t;
|
|
6
|
+
}
|
|
7
|
+
function b(r) {
|
|
8
|
+
var t;
|
|
9
|
+
const e = (t = r.userData) == null ? void 0 : t[l];
|
|
10
|
+
if (!(!f(e) || !g.has(e.role) || typeof e.id != "string" || !e.id.trim() || e.sourceId !== void 0 && (typeof e.sourceId != "string" || !e.sourceId.trim()) || e.allowCameraInside !== void 0 && typeof e.allowCameraInside != "boolean"))
|
|
11
|
+
return e;
|
|
12
|
+
}
|
|
13
|
+
function p(r) {
|
|
14
|
+
var t;
|
|
15
|
+
const e = (t = r.userData) == null ? void 0 : t[h];
|
|
16
|
+
if (!(!f(e) || typeof e.ownerId != "string" || !e.ownerId || !["clone", "effect"].includes(String(e.kind)) || typeof e.sourceId != "string" || !e.sourceId))
|
|
17
|
+
return e;
|
|
18
|
+
}
|
|
19
|
+
function y(r) {
|
|
20
|
+
return p(r) !== void 0;
|
|
21
|
+
}
|
|
22
|
+
function j(r) {
|
|
23
|
+
return [...d.values()].filter((e) => e.scene === r).map(({ object: e }) => e);
|
|
24
|
+
}
|
|
25
|
+
class k {
|
|
26
|
+
constructor(e) {
|
|
27
|
+
if (this.ownerId = e, this.objects = /* @__PURE__ */ new Set(), this.protectedResources = /* @__PURE__ */ new Set(), this.nextObject = 0, !(e != null && e.trim())) throw new Error("RuntimeObjectOwner requires a stable owner id");
|
|
28
|
+
}
|
|
29
|
+
attachRuntimeRoot(e, t, i) {
|
|
30
|
+
if (e === t || e === t.modelRoot || e === i || u(i, e))
|
|
31
|
+
throw new Error("A runtime root cannot be its authored owner or an ancestor of that owner");
|
|
32
|
+
if (!u(i, t.modelRoot))
|
|
33
|
+
throw new Error("A runtime root requires an authored owner beneath modelRoot");
|
|
34
|
+
return this.track(e, i, "effect", t), t.add(e), this.runtimeParent = e, e;
|
|
35
|
+
}
|
|
36
|
+
trackEffect(e, t) {
|
|
37
|
+
if (e === t || u(t, e) || y(t))
|
|
38
|
+
throw new Error("An effect root requires a persistent authored owner outside that root");
|
|
39
|
+
const i = I(e) || m(t);
|
|
40
|
+
if (i && u(e, i.modelRoot))
|
|
41
|
+
throw new Error("Runtime effects must live outside modelRoot");
|
|
42
|
+
return this.track(e, t, "effect", i), e;
|
|
43
|
+
}
|
|
44
|
+
cloneFrom(e, t = this.runtimeParent, i = {}) {
|
|
45
|
+
const n = b(e);
|
|
46
|
+
if (!n || n.sourceId)
|
|
47
|
+
throw new Error("Runtime clones require a direct, template, or generator source with a stable authored id");
|
|
48
|
+
if (!t) throw new Error("Runtime clones require a parent or an attached runtime root");
|
|
49
|
+
const o = I(t) || m(e) || m(t);
|
|
50
|
+
if (o && u(t, o.modelRoot))
|
|
51
|
+
throw new Error("Runtime clones must live outside modelRoot");
|
|
52
|
+
v(e, this.protectedResources);
|
|
53
|
+
const s = e.clone(!0);
|
|
54
|
+
s.traverse((c) => {
|
|
55
|
+
var w, R;
|
|
56
|
+
c !== s && ((w = c.userData) == null || delete w[l], (R = c.userData) == null || delete R[h]), E(c);
|
|
57
|
+
}), s.name = i.name || `${e.name || n.id} (Runtime)`, s.visible = i.visible ?? !0, i.position && s.position.set(...i.position), i.rotation && s.rotation.set(...i.rotation), i.scale && s.scale.set(...i.scale);
|
|
58
|
+
const a = new Set(i.runtimeMutable || ["position", "rotation"]);
|
|
59
|
+
return i.position && a.add("position"), i.rotation && a.add("rotation"), i.scale && a.add("scale"), (i.visible !== void 0 || s.visible !== e.visible) && a.add("visible"), this.markRuntimeObject(s, n, "clone", [...a]), t.add(s), this.objects.add(s), d.set(s, { object: s, owner: e, scene: o }), s;
|
|
60
|
+
}
|
|
61
|
+
cleanup() {
|
|
62
|
+
const e = /* @__PURE__ */ new Set();
|
|
63
|
+
for (const t of this.objects)
|
|
64
|
+
t.removeFromParent(), D(t, this.protectedResources, e), d.delete(t);
|
|
65
|
+
this.objects.clear(), this.protectedResources.clear(), this.runtimeParent = void 0;
|
|
66
|
+
}
|
|
67
|
+
track(e, t, i, n) {
|
|
68
|
+
const o = b(t), s = (o == null ? void 0 : o.id) || t.uuid;
|
|
69
|
+
v(t, this.protectedResources), this.markRuntimeObject(e, o || { role: "direct", id: s }, i), this.objects.add(e), d.set(e, { object: e, owner: t, scene: n });
|
|
70
|
+
}
|
|
71
|
+
markRuntimeObject(e, t, i, n) {
|
|
72
|
+
const o = t.id;
|
|
73
|
+
e.userData[l] = {
|
|
74
|
+
role: t.role,
|
|
75
|
+
id: `${this.ownerId}:${++this.nextObject}`,
|
|
76
|
+
sourceId: o
|
|
77
|
+
}, e.userData[h] = {
|
|
78
|
+
ownerId: this.ownerId,
|
|
79
|
+
kind: i,
|
|
80
|
+
sourceId: o,
|
|
81
|
+
...n != null && n.length ? { overrides: n } : {}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function A(r) {
|
|
86
|
+
if (!r || !g.has(r.role) || typeof r.id != "string" || !r.id.trim())
|
|
87
|
+
throw new Error("Kite3D authoring metadata requires a supported role and stable id");
|
|
88
|
+
if (r.sourceId !== void 0 && (typeof r.sourceId != "string" || !r.sourceId.trim()))
|
|
89
|
+
throw new Error("Kite3D authoring sourceId must be a non-empty string");
|
|
90
|
+
if (r.allowCameraInside !== void 0 && typeof r.allowCameraInside != "boolean")
|
|
91
|
+
throw new Error("Kite3D allowCameraInside must be a boolean");
|
|
92
|
+
return {
|
|
93
|
+
role: r.role,
|
|
94
|
+
id: r.id.trim(),
|
|
95
|
+
...r.sourceId ? { sourceId: r.sourceId.trim() } : {},
|
|
96
|
+
...r.allowCameraInside !== void 0 ? { allowCameraInside: r.allowCameraInside } : {}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function E(r) {
|
|
100
|
+
var t, i;
|
|
101
|
+
const e = r;
|
|
102
|
+
Array.isArray(e.material) ? e.material = e.material.map((n) => {
|
|
103
|
+
var o;
|
|
104
|
+
return ((o = n == null ? void 0 : n.clone) == null ? void 0 : o.call(n)) || n;
|
|
105
|
+
}) : e.material && (e.material = ((i = (t = e.material).clone) == null ? void 0 : i.call(t)) || e.material);
|
|
106
|
+
}
|
|
107
|
+
function I(r) {
|
|
108
|
+
for (let e = r; e; e = e.parent) {
|
|
109
|
+
const t = d.get(e);
|
|
110
|
+
if (t != null && t.scene) return t.scene;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function m(r) {
|
|
114
|
+
let e = r;
|
|
115
|
+
for (; e != null && e.parent; ) e = e.parent;
|
|
116
|
+
return e && "modelRoot" in e ? e : void 0;
|
|
117
|
+
}
|
|
118
|
+
function u(r, e) {
|
|
119
|
+
for (let t = r; t; t = t.parent)
|
|
120
|
+
if (t === e) return !0;
|
|
121
|
+
return !1;
|
|
122
|
+
}
|
|
123
|
+
function v(r, e) {
|
|
124
|
+
r.traverse((t) => {
|
|
125
|
+
const i = t;
|
|
126
|
+
i.geometry && e.add(i.geometry);
|
|
127
|
+
const n = Array.isArray(i.material) ? i.material : [i.material];
|
|
128
|
+
for (const o of n)
|
|
129
|
+
if (o) {
|
|
130
|
+
e.add(o);
|
|
131
|
+
for (const s of Object.values(o))
|
|
132
|
+
f(s) && s.isTexture === !0 && e.add(s);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function D(r, e, t) {
|
|
137
|
+
const i = (n) => {
|
|
138
|
+
!f(n) || e.has(n) || t.has(n) || (t.add(n), typeof n.dispose == "function" && n.dispose());
|
|
139
|
+
};
|
|
140
|
+
r.traverse((n) => {
|
|
141
|
+
const o = n;
|
|
142
|
+
i(o.geometry);
|
|
143
|
+
const s = Array.isArray(o.material) ? o.material : [o.material];
|
|
144
|
+
for (const a of s)
|
|
145
|
+
if (a) {
|
|
146
|
+
for (const c of Object.values(a))
|
|
147
|
+
f(c) && c.isTexture === !0 && i(c);
|
|
148
|
+
i(a);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function f(r) {
|
|
153
|
+
return !!r && typeof r == "object" && !Array.isArray(r);
|
|
154
|
+
}
|
|
155
|
+
export {
|
|
156
|
+
l as KITE3D_AUTHORING_METADATA_KEY,
|
|
157
|
+
h as KITE3D_RUNTIME_METADATA_KEY,
|
|
158
|
+
k as RuntimeObjectOwner,
|
|
159
|
+
b as getAuthoringMetadata,
|
|
160
|
+
p as getRuntimeObjectMetadata,
|
|
161
|
+
j as getTrackedRuntimeObjects,
|
|
162
|
+
y as isRuntimeObject,
|
|
163
|
+
O as setAuthoringMetadata
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=authoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring.js","sources":["../src/authoring.ts"],"sourcesContent":["import type {IObject3D} from 'threepipe'\n\nexport const KITE3D_AUTHORING_METADATA_KEY = 'kite3dAuthoring'\nexport const KITE3D_RUNTIME_METADATA_KEY = 'kite3dRuntime'\n\nexport type AuthoringRole = 'direct' | 'template' | 'generator'\n\nexport interface AuthoringMetadata {\n role: AuthoringRole\n id: string\n sourceId?: string\n allowCameraInside?: boolean\n}\n\nexport interface RuntimeObjectMetadata {\n ownerId: string\n kind: 'clone' | 'effect'\n sourceId: string\n overrides?: RuntimeMutableProperty[]\n}\n\nexport type RuntimeMutableProperty = 'position' | 'rotation' | 'scale' | 'visible' | 'material'\n\nexport interface RuntimeCloneOptions {\n name?: string\n visible?: boolean\n position?: [number, number, number]\n rotation?: [number, number, number]\n scale?: [number, number, number]\n runtimeMutable?: RuntimeMutableProperty[]\n}\n\nexport interface RuntimeScene extends IObject3D {\n modelRoot: IObject3D\n}\n\ninterface TrackedRuntimeObject {\n object: IObject3D\n owner: IObject3D\n scene?: RuntimeScene\n}\n\nconst authoringRoles = new Set<AuthoringRole>(['direct', 'template', 'generator'])\nconst trackedRuntimeObjects = new Map<IObject3D, TrackedRuntimeObject>()\n\n/** Store a validated, serializable authored identity on an object. */\nexport function setAuthoringMetadata(object: IObject3D, metadata: AuthoringMetadata): AuthoringMetadata {\n const value = normalizeAuthoringMetadata(metadata)\n object.userData[KITE3D_AUTHORING_METADATA_KEY] = value\n object.setDirty?.({source: 'Kite3D authoring', change: `userData.${KITE3D_AUTHORING_METADATA_KEY}`})\n return value\n}\n\n/** Read authoring metadata without trusting arbitrary userData. */\nexport function getAuthoringMetadata(object: IObject3D): AuthoringMetadata | undefined {\n const value = object.userData?.[KITE3D_AUTHORING_METADATA_KEY]\n if (!isRecord(value) || !authoringRoles.has(value.role as AuthoringRole)\n || typeof value.id !== 'string' || !value.id.trim()\n || (value.sourceId !== undefined && (typeof value.sourceId !== 'string' || !value.sourceId.trim()))\n || (value.allowCameraInside !== undefined && typeof value.allowCameraInside !== 'boolean')) return undefined\n return value as unknown as AuthoringMetadata\n}\n\nexport function getRuntimeObjectMetadata(object: IObject3D): RuntimeObjectMetadata | undefined {\n const value = object.userData?.[KITE3D_RUNTIME_METADATA_KEY]\n if (!isRecord(value) || typeof value.ownerId !== 'string' || !value.ownerId\n || !['clone', 'effect'].includes(String(value.kind))\n || typeof value.sourceId !== 'string' || !value.sourceId) return undefined\n return value as unknown as RuntimeObjectMetadata\n}\n\nexport function isRuntimeObject(object: IObject3D): boolean {\n return getRuntimeObjectMetadata(object) !== undefined\n}\n\n/** Return the live objects tracked against one viewer scene. */\nexport function getTrackedRuntimeObjects(scene: IObject3D): readonly IObject3D[] {\n return [...trackedRuntimeObjects.values()]\n .filter((record) => record.scene === scene)\n .map(({object}) => object)\n}\n\n/**\n * Owns Play-only roots and clones. A single owner should be created in start()\n * and cleaned in stop(); cleanup is idempotent.\n */\nexport class RuntimeObjectOwner {\n private readonly objects = new Set<IObject3D>()\n private readonly protectedResources = new Set<object>()\n private runtimeParent?: IObject3D\n private nextObject = 0\n\n constructor(readonly ownerId: string) {\n if (!ownerId?.trim()) throw new Error('RuntimeObjectOwner requires a stable owner id')\n }\n\n attachRuntimeRoot<T extends IObject3D>(root: T, scene: RuntimeScene, authoredOwner: IObject3D): T {\n if ((root as IObject3D) === (scene as IObject3D) || root === scene.modelRoot\n || root === authoredOwner || isDescendantOf(authoredOwner, root)) {\n throw new Error('A runtime root cannot be its authored owner or an ancestor of that owner')\n }\n if (!isDescendantOf(authoredOwner, scene.modelRoot)) {\n throw new Error('A runtime root requires an authored owner beneath modelRoot')\n }\n this.track(root, authoredOwner, 'effect', scene)\n scene.add(root)\n this.runtimeParent = root\n return root\n }\n\n trackEffect<T extends IObject3D>(root: T, owner: IObject3D): T {\n if (root === owner || isDescendantOf(owner, root) || isRuntimeObject(owner)) {\n throw new Error('An effect root requires a persistent authored owner outside that root')\n }\n const scene = findTrackedScene(root) || findRuntimeScene(owner)\n if (scene && isDescendantOf(root, scene.modelRoot)) {\n throw new Error('Runtime effects must live outside modelRoot')\n }\n this.track(root, owner, 'effect', scene)\n return root\n }\n\n cloneFrom<T extends IObject3D>(source: T, parent: IObject3D | undefined = this.runtimeParent, options: RuntimeCloneOptions = {}): T {\n const sourceMetadata = getAuthoringMetadata(source)\n if (!sourceMetadata || sourceMetadata.sourceId) {\n throw new Error('Runtime clones require a direct, template, or generator source with a stable authored id')\n }\n if (!parent) throw new Error('Runtime clones require a parent or an attached runtime root')\n const scene = findTrackedScene(parent) || findRuntimeScene(source) || findRuntimeScene(parent)\n if (scene && isDescendantOf(parent, scene.modelRoot)) {\n throw new Error('Runtime clones must live outside modelRoot')\n }\n\n collectResources(source, this.protectedResources)\n const clone = source.clone(true) as T\n clone.traverse((child) => {\n if (child !== clone) {\n delete child.userData?.[KITE3D_AUTHORING_METADATA_KEY]\n delete child.userData?.[KITE3D_RUNTIME_METADATA_KEY]\n }\n cloneMaterials(child)\n })\n clone.name = options.name || `${source.name || sourceMetadata.id} (Runtime)`\n clone.visible = options.visible ?? true\n if (options.position) clone.position.set(...options.position)\n if (options.rotation) clone.rotation.set(...options.rotation)\n if (options.scale) clone.scale.set(...options.scale)\n\n const overrides = new Set<RuntimeMutableProperty>(options.runtimeMutable || ['position', 'rotation'])\n if (options.position) overrides.add('position')\n if (options.rotation) overrides.add('rotation')\n if (options.scale) overrides.add('scale')\n if (options.visible !== undefined || clone.visible !== source.visible) overrides.add('visible')\n this.markRuntimeObject(clone, sourceMetadata, 'clone', [...overrides])\n parent.add(clone)\n this.objects.add(clone)\n trackedRuntimeObjects.set(clone, {object: clone, owner: source, scene})\n return clone\n }\n\n cleanup(): void {\n const disposed = new Set<object>()\n for (const object of this.objects) {\n object.removeFromParent()\n disposeObjectResources(object, this.protectedResources, disposed)\n trackedRuntimeObjects.delete(object)\n }\n this.objects.clear()\n this.protectedResources.clear()\n this.runtimeParent = undefined\n }\n\n private track<T extends IObject3D>(\n object: T,\n owner: IObject3D,\n kind: RuntimeObjectMetadata['kind'],\n scene?: RuntimeScene,\n ): void {\n const ownerMetadata = getAuthoringMetadata(owner)\n const sourceId = ownerMetadata?.id || owner.uuid\n collectResources(owner, this.protectedResources)\n this.markRuntimeObject(object, ownerMetadata || {role: 'direct', id: sourceId}, kind)\n this.objects.add(object)\n trackedRuntimeObjects.set(object, {object, owner, scene})\n }\n\n private markRuntimeObject(\n object: IObject3D,\n source: AuthoringMetadata,\n kind: RuntimeObjectMetadata['kind'],\n overrides?: RuntimeMutableProperty[],\n ): void {\n const sourceId = source.id\n object.userData[KITE3D_AUTHORING_METADATA_KEY] = {\n role: source.role,\n id: `${this.ownerId}:${++this.nextObject}`,\n sourceId,\n } satisfies AuthoringMetadata\n object.userData[KITE3D_RUNTIME_METADATA_KEY] = {\n ownerId: this.ownerId,\n kind,\n sourceId,\n ...(overrides?.length ? {overrides} : {}),\n } satisfies RuntimeObjectMetadata\n }\n}\n\nfunction normalizeAuthoringMetadata(metadata: AuthoringMetadata): AuthoringMetadata {\n if (!metadata || !authoringRoles.has(metadata.role) || typeof metadata.id !== 'string' || !metadata.id.trim()) {\n throw new Error('Kite3D authoring metadata requires a supported role and stable id')\n }\n if (metadata.sourceId !== undefined && (typeof metadata.sourceId !== 'string' || !metadata.sourceId.trim())) {\n throw new Error('Kite3D authoring sourceId must be a non-empty string')\n }\n if (metadata.allowCameraInside !== undefined && typeof metadata.allowCameraInside !== 'boolean') {\n throw new Error('Kite3D allowCameraInside must be a boolean')\n }\n return {\n role: metadata.role,\n id: metadata.id.trim(),\n ...(metadata.sourceId ? {sourceId: metadata.sourceId.trim()} : {}),\n ...(metadata.allowCameraInside !== undefined ? {allowCameraInside: metadata.allowCameraInside} : {}),\n }\n}\n\nfunction cloneMaterials(object: IObject3D): void {\n const renderable = object as IObject3D & {material?: {clone?: () => unknown} | Array<{clone?: () => unknown}>}\n if (Array.isArray(renderable.material)) {\n renderable.material = renderable.material.map((material) => material?.clone?.() || material) as typeof renderable.material\n } else if (renderable.material) {\n renderable.material = (renderable.material.clone?.() || renderable.material) as typeof renderable.material\n }\n}\n\nfunction findTrackedScene(object: IObject3D): RuntimeScene | undefined {\n for (let current: IObject3D | null = object; current; current = current.parent as IObject3D | null) {\n const record = trackedRuntimeObjects.get(current)\n if (record?.scene) return record.scene\n }\n return undefined\n}\n\nfunction findRuntimeScene(object: IObject3D): RuntimeScene | undefined {\n let current: IObject3D | null = object\n while (current?.parent) current = current.parent as IObject3D\n return current && 'modelRoot' in current ? current as RuntimeScene : undefined\n}\n\nfunction isDescendantOf(object: IObject3D, ancestor: IObject3D): boolean {\n for (let current: IObject3D | null = object; current; current = current.parent as IObject3D | null) {\n if (current === ancestor) return true\n }\n return false\n}\n\nfunction collectResources(object: IObject3D, target: Set<object>): void {\n object.traverse((child) => {\n const resourceOwner = child as IObject3D & {geometry?: object, material?: object | object[]}\n if (resourceOwner.geometry) target.add(resourceOwner.geometry)\n const materials = Array.isArray(resourceOwner.material) ? resourceOwner.material : [resourceOwner.material]\n for (const material of materials) {\n if (!material) continue\n target.add(material)\n for (const value of Object.values(material)) {\n if (isRecord(value) && value.isTexture === true) target.add(value)\n }\n }\n })\n}\n\nfunction disposeObjectResources(object: IObject3D, protectedResources: Set<object>, disposed: Set<object>): void {\n const dispose = (resource: unknown) => {\n if (!isRecord(resource) || protectedResources.has(resource) || disposed.has(resource)) return\n disposed.add(resource)\n if (typeof resource.dispose === 'function') resource.dispose()\n }\n object.traverse((child) => {\n const resourceOwner = child as IObject3D & {geometry?: object, material?: object | object[]}\n dispose(resourceOwner.geometry)\n const materials = Array.isArray(resourceOwner.material) ? resourceOwner.material : [resourceOwner.material]\n for (const material of materials) {\n if (!material) continue\n for (const value of Object.values(material)) {\n if (isRecord(value) && value.isTexture === true) dispose(value)\n }\n dispose(material)\n }\n })\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n}\n"],"names":["KITE3D_AUTHORING_METADATA_KEY","KITE3D_RUNTIME_METADATA_KEY","authoringRoles","trackedRuntimeObjects","setAuthoringMetadata","object","metadata","_a","value","normalizeAuthoringMetadata","getAuthoringMetadata","isRecord","getRuntimeObjectMetadata","isRuntimeObject","getTrackedRuntimeObjects","scene","record","RuntimeObjectOwner","ownerId","root","authoredOwner","isDescendantOf","owner","findTrackedScene","findRuntimeScene","source","parent","options","sourceMetadata","collectResources","clone","child","_b","cloneMaterials","overrides","disposed","disposeObjectResources","kind","ownerMetadata","sourceId","renderable","material","current","ancestor","target","resourceOwner","materials","protectedResources","d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O,EAAQA,KAAU,OAAOA,KAAU,YAAY,CAAC,MAAM,QAAQA,CAAK;AAC9E;"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { IObject3D, ThreeViewer } from 'threepipe';
|
|
2
|
+
export type AuthoringFailureCode = 'NO_VISIBLE_AUTHORED_CONTENT' | 'GENERATOR_PREVIEW_MISSING' | 'RUNTIME_OBJECT_AFTER_STOP' | 'MISSING_AUTHORING_SOURCE' | 'RUNTIME_SOURCE_DRIFT' | 'CAMERA_NOT_USEFUL' | 'CAMERA_CONTAINMENT_UNVERIFIED' | 'PERSISTENCE_DRIFT';
|
|
3
|
+
export interface AuthoringValidationIssue {
|
|
4
|
+
code: AuthoringFailureCode;
|
|
5
|
+
severity: 'error' | 'warning';
|
|
6
|
+
message: string;
|
|
7
|
+
object?: {
|
|
8
|
+
uuid: string;
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
path?: string;
|
|
12
|
+
before?: unknown;
|
|
13
|
+
after?: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface AuthoringQualityReport {
|
|
16
|
+
ok: boolean;
|
|
17
|
+
status: 'pass' | 'fail';
|
|
18
|
+
summary: string;
|
|
19
|
+
issues: AuthoringValidationIssue[];
|
|
20
|
+
checks: {
|
|
21
|
+
visibleAuthoredContent: boolean;
|
|
22
|
+
selectableAuthoredContent: boolean;
|
|
23
|
+
relationshipsValid: boolean;
|
|
24
|
+
generatorPreviews: boolean;
|
|
25
|
+
cameraUseful: boolean;
|
|
26
|
+
};
|
|
27
|
+
metrics: {
|
|
28
|
+
authoredObjectCount: number;
|
|
29
|
+
renderableCount: number;
|
|
30
|
+
visibleRenderableCount: number;
|
|
31
|
+
selectableCount: number;
|
|
32
|
+
generatorCount: number;
|
|
33
|
+
generatorPreviewCount: number;
|
|
34
|
+
cameraFramedRenderableCount: number;
|
|
35
|
+
cameraInsideRenderableCount: number;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface RuntimeCleanupReport {
|
|
39
|
+
ok: boolean;
|
|
40
|
+
status: 'pass' | 'fail';
|
|
41
|
+
summary: string;
|
|
42
|
+
issues: AuthoringValidationIssue[];
|
|
43
|
+
trackedObjectCount: number;
|
|
44
|
+
outsideRenderableCount: number;
|
|
45
|
+
}
|
|
46
|
+
export interface SemanticSceneSnapshot {
|
|
47
|
+
schemaVersion: 1;
|
|
48
|
+
scene: unknown[];
|
|
49
|
+
}
|
|
50
|
+
export interface PersistenceChange {
|
|
51
|
+
path: string;
|
|
52
|
+
before: unknown;
|
|
53
|
+
after: unknown;
|
|
54
|
+
}
|
|
55
|
+
export interface PersistenceReport {
|
|
56
|
+
ok: boolean;
|
|
57
|
+
status: 'pass' | 'fail';
|
|
58
|
+
summary: string;
|
|
59
|
+
issues: AuthoringValidationIssue[];
|
|
60
|
+
changes: PersistenceChange[];
|
|
61
|
+
beforeBytes: number;
|
|
62
|
+
afterBytes: number;
|
|
63
|
+
}
|
|
64
|
+
type ViewerLike = Pick<ThreeViewer, 'scene'>;
|
|
65
|
+
type SceneLike = IObject3D & {
|
|
66
|
+
modelRoot: IObject3D;
|
|
67
|
+
mainCamera?: IObject3D;
|
|
68
|
+
defaultCamera?: IObject3D;
|
|
69
|
+
};
|
|
70
|
+
/** Validate the stopped authoring hierarchy, its sources, previews, and saved camera. */
|
|
71
|
+
export declare function authoringQualityReport(viewer: ViewerLike): AuthoringQualityReport;
|
|
72
|
+
/** Validate that Play-only content was removed and its authored sources stayed valid. */
|
|
73
|
+
export declare function runtimeCleanupReport(viewer: ViewerLike): RuntimeCleanupReport;
|
|
74
|
+
/** Capture the supported saved semantics without transient engine identities. */
|
|
75
|
+
export declare function semanticSceneSnapshot(source: ViewerLike | SceneLike): SemanticSceneSnapshot;
|
|
76
|
+
/** Compare names, transforms, component state, and authored source relationships. */
|
|
77
|
+
export declare function persistenceReport(before: unknown, after: unknown): PersistenceReport;
|
|
78
|
+
export interface GameValidationResult {
|
|
79
|
+
status: 'pass' | 'fail';
|
|
80
|
+
summary: string;
|
|
81
|
+
checks?: Record<string, boolean | number | string>;
|
|
82
|
+
}
|
|
83
|
+
export interface GameValidationReport {
|
|
84
|
+
ok: boolean;
|
|
85
|
+
status: 'pass' | 'fail';
|
|
86
|
+
summary: string;
|
|
87
|
+
results: GameValidationResult[];
|
|
88
|
+
}
|
|
89
|
+
export type GameValidationFunction = () => GameValidationResult | boolean | void | Promise<GameValidationResult | boolean | void>;
|
|
90
|
+
interface GameHookHost {
|
|
91
|
+
registerGameValidation(fn: GameValidationFunction): () => void;
|
|
92
|
+
publishGameTelemetry(value: object): () => void;
|
|
93
|
+
runGameValidation(): Promise<GameValidationReport>;
|
|
94
|
+
dispose(): void;
|
|
95
|
+
}
|
|
96
|
+
/** Register a project-defined gameplay assertion for the currently starting game. */
|
|
97
|
+
export declare function registerGameValidation(fn: GameValidationFunction): () => void;
|
|
98
|
+
/** Publish an immutable telemetry snapshot on window.kite3dGame.telemetry. */
|
|
99
|
+
export declare function publishGameTelemetry(value: object): () => void;
|
|
100
|
+
/** Install the per-createGame hook host before project modules are evaluated. */
|
|
101
|
+
export declare function installGameHooks(): GameHookHost;
|
|
102
|
+
declare global {
|
|
103
|
+
interface Window {
|
|
104
|
+
kite3dGame?: Readonly<{
|
|
105
|
+
readonly telemetry: object | undefined;
|
|
106
|
+
validate(): Promise<GameValidationReport>;
|
|
107
|
+
}>;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export {};
|