@pinkaphant/kolmo 0.4.4 → 0.4.5

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.
Files changed (164) hide show
  1. package/README.md +60 -6
  2. package/bin/kolmo.mjs +455 -15
  3. package/dist/engine/index.d.ts +2 -0
  4. package/dist/engine/index.js +7 -5
  5. package/dist/engine/kolmoActions.js +24 -9
  6. package/dist/engine/kolmoActions.js.map +1 -1
  7. package/dist/engine/kolmoActor.js +19 -31
  8. package/dist/engine/kolmoActor.js.map +1 -1
  9. package/dist/engine/kolmoActorHelpers.d.ts +24 -0
  10. package/dist/engine/kolmoActorHelpers.js +64 -0
  11. package/dist/engine/kolmoActorHelpers.js.map +1 -0
  12. package/dist/engine/kolmoGame.js +4 -1
  13. package/dist/engine/kolmoGame.js.map +1 -1
  14. package/dist/engine/kolmoHud.js +34 -15
  15. package/dist/engine/kolmoHud.js.map +1 -1
  16. package/dist/engine/kolmoInput.d.ts +2 -0
  17. package/dist/engine/kolmoInput.js +12 -12
  18. package/dist/engine/kolmoInput.js.map +1 -1
  19. package/dist/engine/kolmoLongDrive.d.ts +1 -1
  20. package/dist/engine/kolmoLongDrive.js +10 -8
  21. package/dist/engine/kolmoLongDrive.js.map +1 -1
  22. package/dist/engine/kolmoPilotMesh.js +189 -48
  23. package/dist/engine/kolmoPilotMesh.js.map +1 -1
  24. package/dist/engine/kolmoTouchOverlay.d.ts +21 -0
  25. package/dist/engine/kolmoTouchOverlay.js +326 -0
  26. package/dist/engine/kolmoTouchOverlay.js.map +1 -0
  27. package/dist/engine/kolmoTouchState.d.ts +50 -0
  28. package/dist/engine/kolmoTouchState.js +210 -0
  29. package/dist/engine/kolmoTouchState.js.map +1 -0
  30. package/dist/engine/kolmoVehicleConfig.d.ts +2 -0
  31. package/dist/engine/kolmoVehicleConfig.js +8 -4
  32. package/dist/engine/kolmoVehicleConfig.js.map +1 -1
  33. package/dist/engine/kolmoVehicleDriver.d.ts +1 -0
  34. package/dist/engine/kolmoVehicleDriver.js +26 -50
  35. package/dist/engine/kolmoVehicleDriver.js.map +1 -1
  36. package/dist/engine/kolmoVehicleInner.js +31 -19
  37. package/dist/engine/kolmoVehicleInner.js.map +1 -1
  38. package/dist/engine/kolmoWorld.js +6 -2
  39. package/dist/engine/kolmoWorld.js.map +1 -1
  40. package/dist/engine/longDriveKit.d.ts +6 -1
  41. package/dist/engine/longDriveKit.js +8 -5
  42. package/dist/engine/longDriveKit.js.map +1 -1
  43. package/dist/engine/macroCellBuilder.d.ts +10 -0
  44. package/dist/engine/macroCellBuilder.js +101 -18
  45. package/dist/engine/macroCellBuilder.js.map +1 -1
  46. package/dist/engine/mainlandMacroCell.js +18 -9
  47. package/dist/engine/mainlandMacroCell.js.map +1 -1
  48. package/dist/importer/DomainWorkshopPanel.d.ts +3 -3
  49. package/dist/importer/DomainWorkshopPanel.js +148 -44
  50. package/dist/importer/DomainWorkshopPanel.js.map +1 -1
  51. package/dist/importer/GateHudBar.d.ts +2 -0
  52. package/dist/importer/GateHudBar.js +113 -35
  53. package/dist/importer/GateHudBar.js.map +1 -1
  54. package/dist/importer/GlbImportGate.js +16 -3
  55. package/dist/importer/GlbImportGate.js.map +1 -1
  56. package/dist/importer/LiveDrivePads.js +5 -3
  57. package/dist/importer/LiveDrivePads.js.map +1 -1
  58. package/dist/importer/Step1CalibrationPlinth.js +2 -2
  59. package/dist/importer/WheelRingHandles3D.js +2 -1
  60. package/dist/importer/WheelRingHandles3D.js.map +1 -1
  61. package/dist/importer/chopShopActions.js +20 -16
  62. package/dist/importer/chopShopActions.js.map +1 -1
  63. package/dist/importer/chopShopHandlers.js +16 -9
  64. package/dist/importer/chopShopHandlers.js.map +1 -1
  65. package/dist/importer/chopShopIoActions.d.ts +2 -0
  66. package/dist/importer/chopShopIoActions.js +33 -2
  67. package/dist/importer/chopShopIoActions.js.map +1 -1
  68. package/dist/importer/cylinderBooleanSlice.js.map +1 -1
  69. package/dist/importer/fusedWheelDetect.d.ts +2 -2
  70. package/dist/importer/fusedWheelDetect.js +227 -106
  71. package/dist/importer/fusedWheelDetect.js.map +1 -1
  72. package/dist/importer/fusedWheelFit.d.ts +6 -0
  73. package/dist/importer/fusedWheelFit.js +82 -1
  74. package/dist/importer/fusedWheelFit.js.map +1 -1
  75. package/dist/importer/gateStore.d.ts +2 -2
  76. package/dist/importer/gateStore.js +4 -3
  77. package/dist/importer/gateStore.js.map +1 -1
  78. package/dist/importer/glbNormalizer.js +5 -0
  79. package/dist/importer/glbNormalizer.js.map +1 -1
  80. package/dist/importer/importerWebMcpTools.js +3 -2
  81. package/dist/importer/importerWebMcpTools.js.map +1 -1
  82. package/dist/importer/index.d.ts +4 -2
  83. package/dist/importer/index.js +7 -3
  84. package/dist/importer/khrCarGeometryMass.d.ts +20 -0
  85. package/dist/importer/khrCarGeometryMass.js +125 -0
  86. package/dist/importer/khrCarGeometryMass.js.map +1 -0
  87. package/dist/importer/khrCarPlanHelpers.js +12 -22
  88. package/dist/importer/khrCarPlanHelpers.js.map +1 -1
  89. package/dist/importer/khrCarPlanner.js +52 -85
  90. package/dist/importer/khrCarPlanner.js.map +1 -1
  91. package/dist/importer/proceduralC12AndCraft.d.ts +18 -0
  92. package/dist/importer/proceduralC12AndCraft.js +302 -0
  93. package/dist/importer/proceduralC12AndCraft.js.map +1 -0
  94. package/dist/importer/proceduralDomainBuilders.d.ts +10 -0
  95. package/dist/importer/proceduralDomainBuilders.js +346 -0
  96. package/dist/importer/proceduralDomainBuilders.js.map +1 -0
  97. package/dist/importer/proceduralPersonAndProp.d.ts +8 -0
  98. package/dist/importer/proceduralPersonAndProp.js +303 -0
  99. package/dist/importer/proceduralPersonAndProp.js.map +1 -0
  100. package/dist/importer/starterScene.d.ts +3 -1
  101. package/dist/importer/starterScene.js +69 -13
  102. package/dist/importer/starterScene.js.map +1 -1
  103. package/dist/importer/universalGateBake.js +43 -11
  104. package/dist/importer/universalGateBake.js.map +1 -1
  105. package/dist/importer/useChopShopController.d.ts +3 -1
  106. package/dist/importer/useChopShopController.js +33 -18
  107. package/dist/importer/useChopShopController.js.map +1 -1
  108. package/dist/importer/useChopShopState.d.ts +1 -1
  109. package/dist/importer/useChopShopState.js +35 -9
  110. package/dist/importer/useChopShopState.js.map +1 -1
  111. package/dist/importer/wheelCutterHelpers.d.ts +7 -4
  112. package/dist/importer/wheelCutterHelpers.js +58 -28
  113. package/dist/importer/wheelCutterHelpers.js.map +1 -1
  114. package/dist/index.d.ts +4 -0
  115. package/dist/index.js +20 -7
  116. package/dist/junk/DestructibleTarget.js +9 -3
  117. package/dist/junk/DestructibleTarget.js.map +1 -1
  118. package/dist/junk/ShardPieces.js +10 -2
  119. package/dist/junk/ShardPieces.js.map +1 -1
  120. package/dist/junk/index.d.ts +1 -0
  121. package/dist/junk/index.js +2 -1
  122. package/dist/junk/junkProceduralScenes.d.ts +12 -0
  123. package/dist/junk/junkProceduralScenes.js +220 -0
  124. package/dist/junk/junkProceduralScenes.js.map +1 -0
  125. package/dist/sand3d/KolmoSand3D.d.ts +19 -0
  126. package/dist/sand3d/KolmoSand3D.js +92 -0
  127. package/dist/sand3d/KolmoSand3D.js.map +1 -0
  128. package/dist/sand3d/Sand3dWorkshopSection.d.ts +8 -0
  129. package/dist/sand3d/Sand3dWorkshopSection.js +117 -0
  130. package/dist/sand3d/Sand3dWorkshopSection.js.map +1 -0
  131. package/dist/sand3d/gateBakeHelpers.d.ts +21 -0
  132. package/dist/sand3d/gateBakeHelpers.js +225 -0
  133. package/dist/sand3d/gateBakeHelpers.js.map +1 -0
  134. package/dist/sand3d/gateDoorwayBake.d.ts +12 -0
  135. package/dist/sand3d/gateDoorwayBake.js +203 -0
  136. package/dist/sand3d/gateDoorwayBake.js.map +1 -0
  137. package/dist/sand3d/index.d.ts +3 -0
  138. package/dist/sand3d/index.js +4 -0
  139. package/dist/sand3d/index.js.map +1 -0
  140. package/dist/sand3d/sand3dAssetLoader.d.ts +28 -0
  141. package/dist/sand3d/sand3dAssetLoader.js +177 -0
  142. package/dist/sand3d/sand3dAssetLoader.js.map +1 -0
  143. package/dist/suika/KolmoSuikaOrb.d.ts +33 -0
  144. package/dist/suika/KolmoSuikaOrb.js +375 -0
  145. package/dist/suika/KolmoSuikaOrb.js.map +1 -0
  146. package/dist/suika/index.d.ts +4 -0
  147. package/dist/suika/index.js +5 -0
  148. package/dist/suika/index.js.map +1 -0
  149. package/dist/suika/suikaArbiter.d.ts +60 -0
  150. package/dist/suika/suikaArbiter.js +265 -0
  151. package/dist/suika/suikaArbiter.js.map +1 -0
  152. package/dist/suika/suikaGeometry.d.ts +10 -0
  153. package/dist/suika/suikaGeometry.js +251 -0
  154. package/dist/suika/suikaGeometry.js.map +1 -0
  155. package/dist/suika/suikaTypes.d.ts +74 -0
  156. package/dist/suika/suikaTypes.js +196 -0
  157. package/dist/suika/suikaTypes.js.map +1 -0
  158. package/dist/world/index.d.ts +1 -1
  159. package/dist/world/index.js +2 -2
  160. package/dist/world/worldTypes.d.ts +4 -0
  161. package/dist/world/worldTypes.js +21 -1
  162. package/dist/world/worldTypes.js.map +1 -1
  163. package/docs/api-reference.md +82 -125
  164. package/package.json +14 -6
@@ -0,0 +1,117 @@
1
+ import { SAND3D_RECIPES, compileSand3dAssembly, measureNaturalSceneSpanM, parseSand3dSource } from "./sand3dAssetLoader.js";
2
+ import { useState } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ // src/sand3d/Sand3dWorkshopSection.tsx
5
+ var codeAreaStyle = {
6
+ width: "100%",
7
+ minHeight: 132,
8
+ boxSizing: "border-box",
9
+ padding: 8,
10
+ borderRadius: 6,
11
+ background: "#07090d",
12
+ border: "1px solid rgba(56, 189, 248, 0.28)",
13
+ color: "#e2e8f0",
14
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
15
+ fontSize: 11,
16
+ lineHeight: 1.4,
17
+ resize: "vertical"
18
+ };
19
+ function attachCompiledSand3dUserData(scene, compiled, source) {
20
+ const span = measureNaturalSceneSpanM(scene);
21
+ const totalMass = compiled.specs.reduce((sum, s) => sum + (s.motion?.mass ?? 0), 0);
22
+ scene.userData.sand3dSpecs = compiled.specs;
23
+ scene.userData.sand3dExtras = compiled.sceneExtras;
24
+ scene.userData.sand3dAssembly = compiled.assembly;
25
+ scene.userData.sand3dSource = source;
26
+ scene.userData.naturalTargetMeters = span.lengthZM;
27
+ return {
28
+ targetMeters: Number(span.lengthZM.toFixed(4)),
29
+ massKg: Number(Math.max(.25, totalMass || 12).toFixed(2))
30
+ };
31
+ }
32
+ function Sand3dWorkshopSection({ btnStyle, onForgeScene, onStatus }) {
33
+ const initialRecipe = SAND3D_RECIPES[0];
34
+ const [code, setCode] = useState(() => initialRecipe?.source ?? "import sand3d as s3d\n");
35
+ const [activeId, setActiveId] = useState(() => initialRecipe?.id ?? "cnc_mounting_bracket");
36
+ const applyRecipe = (recipe) => {
37
+ try {
38
+ setActiveId(recipe.id);
39
+ setCode(recipe.source);
40
+ const compiled = compileSand3dAssembly(recipe.build());
41
+ const meta = attachCompiledSand3dUserData(compiled.scene, compiled, recipe.source);
42
+ onForgeScene(recipe.id, compiled.scene, meta.targetMeters, meta.massKg);
43
+ onStatus(`Compiled ${recipe.label} (${recipe.units})`);
44
+ } catch (err) {
45
+ onStatus(err instanceof Error ? err.message : "Sand3D recipe compile error.");
46
+ }
47
+ };
48
+ const compileEditorCode = () => {
49
+ try {
50
+ const asm = parseSand3dSource(code);
51
+ const compiled = compileSand3dAssembly(asm);
52
+ const meta = attachCompiledSand3dUserData(compiled.scene, compiled, code);
53
+ const label = asm.name || activeId || "sand3d_custom";
54
+ onForgeScene(label, compiled.scene, meta.targetMeters, meta.massKg);
55
+ onStatus(`Compiled ${label} · ${compiled.specs.length} KHR node(s)`);
56
+ } catch (err) {
57
+ onStatus(err instanceof Error ? err.message : "Sand3D script compile error.");
58
+ }
59
+ };
60
+ return /* @__PURE__ */ jsxs("div", {
61
+ style: {
62
+ display: "grid",
63
+ gap: 6
64
+ },
65
+ children: [
66
+ /* @__PURE__ */ jsx("div", {
67
+ style: {
68
+ display: "grid",
69
+ gridTemplateColumns: "1fr 1fr",
70
+ gap: 4
71
+ },
72
+ children: SAND3D_RECIPES.map((recipe) => /* @__PURE__ */ jsx("button", {
73
+ type: "button",
74
+ style: {
75
+ ...btnStyle,
76
+ padding: "5px 7px",
77
+ borderColor: activeId === recipe.id ? "#38bdf8" : "rgba(255,255,255,0.16)"
78
+ },
79
+ onClick: () => applyRecipe(recipe),
80
+ children: recipe.label
81
+ }, recipe.id))
82
+ }),
83
+ /* @__PURE__ */ jsx("label", {
84
+ style: {
85
+ fontSize: 11,
86
+ color: "#94a3b8"
87
+ },
88
+ htmlFor: "kolmo-sand3d-editor",
89
+ children: "Sand3D script (.sand3d / .s3d)"
90
+ }),
91
+ /* @__PURE__ */ jsx("textarea", {
92
+ id: "kolmo-sand3d-editor",
93
+ "aria-label": "Sand3D Script",
94
+ value: code,
95
+ spellCheck: false,
96
+ onChange: (e) => setCode(e.target.value),
97
+ style: codeAreaStyle
98
+ }),
99
+ /* @__PURE__ */ jsx("button", {
100
+ type: "button",
101
+ style: {
102
+ ...btnStyle,
103
+ textAlign: "center",
104
+ fontWeight: 600,
105
+ background: "rgba(56, 189, 248, 0.16)",
106
+ borderColor: "#38bdf8",
107
+ color: "#38bdf8"
108
+ },
109
+ onClick: compileEditorCode,
110
+ children: "Compile Sand3D"
111
+ })
112
+ ]
113
+ });
114
+ }
115
+ export { Sand3dWorkshopSection };
116
+
117
+ //# sourceMappingURL=Sand3dWorkshopSection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sand3dWorkshopSection.js","names":[],"sources":["../../src/sand3d/Sand3dWorkshopSection.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport type * as THREE from \"three\";\nimport {\n SAND3D_RECIPES,\n compileSand3dAssembly,\n parseSand3dSource,\n type Sand3dRecipe,\n} from \"./sand3dAssetLoader.js\";\nimport { measureNaturalSceneSpanM } from \"./sand3dAssetLoader.js\";\n\nexport interface Sand3dWorkshopSectionProps {\n readonly btnStyle: React.CSSProperties;\n readonly onForgeScene: (label: string, scene: THREE.Group, targetMeters: number, massKg: number) => void;\n readonly onStatus: (message: string) => void;\n}\n\nconst codeAreaStyle: React.CSSProperties = {\n width: \"100%\",\n minHeight: 132,\n boxSizing: \"border-box\",\n padding: 8,\n borderRadius: 6,\n background: \"#07090d\",\n border: \"1px solid rgba(56, 189, 248, 0.28)\",\n color: \"#e2e8f0\",\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, monospace\",\n fontSize: 11,\n lineHeight: 1.4,\n resize: \"vertical\",\n};\n\nfunction attachCompiledSand3dUserData(\n scene: THREE.Group,\n compiled: ReturnType<typeof compileSand3dAssembly>,\n source: string,\n): { targetMeters: number; massKg: number } {\n const span = measureNaturalSceneSpanM(scene);\n const totalMass = compiled.specs.reduce((sum, s) => sum + (s.motion?.mass ?? 0), 0);\n scene.userData.sand3dSpecs = compiled.specs;\n scene.userData.sand3dExtras = compiled.sceneExtras;\n scene.userData.sand3dAssembly = compiled.assembly;\n scene.userData.sand3dSource = source;\n scene.userData.naturalTargetMeters = span.lengthZM;\n return {\n targetMeters: Number(span.lengthZM.toFixed(4)),\n massKg: Number(Math.max(0.25, totalMass || 12).toFixed(2)),\n };\n}\n\nexport function Sand3dWorkshopSection({\n btnStyle,\n onForgeScene,\n onStatus,\n}: Sand3dWorkshopSectionProps): React.JSX.Element {\n const initialRecipe = SAND3D_RECIPES[0];\n const [code, setCode] = useState<string>(() => initialRecipe?.source ?? \"import sand3d as s3d\\n\");\n const [activeId, setActiveId] = useState<string>(() => initialRecipe?.id ?? \"cnc_mounting_bracket\");\n\n const applyRecipe = (recipe: Sand3dRecipe): void => {\n try {\n setActiveId(recipe.id);\n setCode(recipe.source);\n const compiled = compileSand3dAssembly(recipe.build());\n const meta = attachCompiledSand3dUserData(compiled.scene, compiled, recipe.source);\n onForgeScene(recipe.id, compiled.scene, meta.targetMeters, meta.massKg);\n onStatus(`Compiled ${recipe.label} (${recipe.units})`);\n } catch (err) {\n onStatus(err instanceof Error ? err.message : \"Sand3D recipe compile error.\");\n }\n };\n\n const compileEditorCode = (): void => {\n try {\n const asm = parseSand3dSource(code);\n const compiled = compileSand3dAssembly(asm);\n const meta = attachCompiledSand3dUserData(compiled.scene, compiled, code);\n const label = asm.name || activeId || \"sand3d_custom\";\n onForgeScene(label, compiled.scene, meta.targetMeters, meta.massKg);\n onStatus(`Compiled ${label} · ${compiled.specs.length} KHR node(s)`);\n } catch (err) {\n onStatus(err instanceof Error ? err.message : \"Sand3D script compile error.\");\n }\n };\n\n return (\n <div style={{ display: \"grid\", gap: 6 }}>\n <div style={{ display: \"grid\", gridTemplateColumns: \"1fr 1fr\", gap: 4 }}>\n {SAND3D_RECIPES.map((recipe) => (\n <button\n key={recipe.id}\n type=\"button\"\n style={{\n ...btnStyle,\n padding: \"5px 7px\",\n borderColor: activeId === recipe.id ? \"#38bdf8\" : \"rgba(255,255,255,0.16)\",\n }}\n onClick={() => applyRecipe(recipe)}\n >\n {recipe.label}\n </button>\n ))}\n </div>\n <label style={{ fontSize: 11, color: \"#94a3b8\" }} htmlFor=\"kolmo-sand3d-editor\">\n Sand3D script (.sand3d / .s3d)\n </label>\n <textarea\n id=\"kolmo-sand3d-editor\"\n aria-label=\"Sand3D Script\"\n value={code}\n spellCheck={false}\n onChange={(e) => setCode(e.target.value)}\n style={codeAreaStyle}\n />\n <button\n type=\"button\"\n style={{\n ...btnStyle,\n textAlign: \"center\",\n fontWeight: 600,\n background: \"rgba(56, 189, 248, 0.16)\",\n borderColor: \"#38bdf8\",\n color: \"#38bdf8\",\n }}\n onClick={compileEditorCode}\n >\n Compile Sand3D\n </button>\n </div>\n );\n}\n"],"mappings":";;;;AAgBA,IAAM,gBAAqC;CACvC,OAAO;CACP,WAAW;CACX,WAAW;CACX,SAAS;CACT,cAAc;CACd,YAAY;CACZ,QAAQ;CACR,OAAO;CACP,YAAY;CACZ,UAAU;CACV,YA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Y;GACtC,aAAa,OAAO,SAAS,OAAO,KAAK,cAAc,KAAK,MAAM;GAClE,SAAS,YAAY,MAAM,KAAK,SAAS,MAAM,OAAO,aAAa;EACvE,SAAS,KAAK;GACV,SAAS,eAAe,QAAQ,IAAI,UAAU,8BAA8B;EAChF;CACJ;CAEA,OACI,qBAAC,OAAD;EAAK,OAAO;GAAE,SAAS;GAAQ,KAAK;EAAE;EAAtC,UAAA;GACI,oBAAC,OAAD;IAAK,OAAO;KAAE,SAAS;KAAQ,qBAAqB;KAAW,KAAK;IAAE;IACjE,UAAA,eAAe,KAAK,WACjB,oBAAC,UAAD;KAEI,MAAK;KACL,OAAO;MACH,GAAG;MACH,SAAS;MACT,aAAa,aAAa,OAAO,KAAK,YAAY;KACtD;KACA,eAAe,YAAY,MAAM;KAEhC,UAAA,OAAO;IACJ,GAVC,OAAO,EAUR,CACX;GACA,CAAA;GACL,oBAAC,SAAD;IAAO,OAAO;KAAE,UAAU;KAAI,OAAO;IAAU;IAAG,SAAQ;IAAsB,UAAA;GAEzE,CAAA;GACP,oBAAC,YAAD;IACI,IAAG;IACH,cAAW;IACX,OAAO;IACP,YAAY;IACZ,WAAW,MAAM,QAAQ,EAAE,OAAO,KAAK;IACvC,OAAO;GACV,CAAA;GACD,oBAAC,UAAD;IACI,MAAK;IACL,OAAO;KACH,GAAG;KACH,WAAW;KACX,YAAY;KACZ,YAAY;KACZ,aAAa;KACb,OAAO;IACX;IACA,SAAS;IACZ,UAAA;GAEO,CAAA;EACP;;AAEb"}
@@ -0,0 +1,21 @@
1
+ import * as THREE from "three";
2
+ import type { KhrAssetBundle } from "@khr3/core";
3
+ import { type PaperShellPresetId } from "@khr3/vehicles/paper-shell";
4
+ import type { KolmoAuthoredNodePatch } from "../schema/kolmoSchema.js";
5
+ import { bakeHingedDoorwayScene } from "./gateDoorwayBake.js";
6
+ export { bakeHingedDoorwayScene };
7
+ export declare function buildProceduralPaperShellCarGroup(presetId: PaperShellPresetId): {
8
+ scene: THREE.Group;
9
+ lengthM: number;
10
+ massKg: number;
11
+ };
12
+ export declare function bakeSand3dGateScene(baseScene: THREE.Group | null, name: string, patches: readonly KolmoAuthoredNodePatch[]): Promise<{
13
+ glbBytes: Uint8Array;
14
+ bundle: KhrAssetBundle;
15
+ worldKind: "vehicle" | "prop";
16
+ } | null>;
17
+ export declare function bakeSocketCraftScene(baseScene: THREE.Group, name: string, massKg: number, powerOrThrust: number, patches: readonly KolmoAuthoredNodePatch[]): Promise<{
18
+ glbBytes: Uint8Array;
19
+ bundle: KhrAssetBundle;
20
+ worldKind: "vehicle";
21
+ } | null>;
@@ -0,0 +1,225 @@
1
+ import { disambiguateExplicitPatches } from "../schema/kolmoStamp.js";
2
+ import { boxInertia, collectPreservedRigPatches, r4 } from "../importer/khrCraftPropCompiler.js";
3
+ import { collectSceneNodeNames, collectSpecNodeNames, disambiguateSubtreeNodeNames, ensureRootNameUnique } from "../importer/khrNodeNameGuard.js";
4
+ import { cloneForNormalize } from "../importer/sceneSiNormalize.js";
5
+ import { bakeHingedDoorwayScene, exportStampedGateScene } from "./gateDoorwayBake.js";
6
+ import { SAND3D_RECIPES, compileSand3dAssembly } from "./sand3dAssetLoader.js";
7
+ import * as THREE from "three";
8
+ import { PAPER_SHELL_PRESETS, buildPaperShellAssembly } from "@khr3/vehicles/paper-shell";
9
+ // src/sand3d/gateBakeHelpers.ts
10
+ function buildProceduralPaperShellCarGroup(presetId) {
11
+ const asm = buildPaperShellAssembly(presetId, "dc-smooth");
12
+ const root = new THREE.Group();
13
+ root.name = `PaperShell_${presetId}`;
14
+ const mkMesh = (name, posArr, normArr, hex, offset) => {
15
+ const geo = new THREE.BufferGeometry();
16
+ geo.setAttribute("position", new THREE.BufferAttribute(new Float32Array(posArr), 3));
17
+ geo.setAttribute("normal", new THREE.BufferAttribute(new Float32Array(normArr), 3));
18
+ geo.computeBoundingBox();
19
+ const m = new THREE.Mesh(geo, new THREE.MeshStandardMaterial({
20
+ color: hex,
21
+ roughness: .48,
22
+ metalness: .16,
23
+ flatShading: true
24
+ }));
25
+ m.name = name;
26
+ m.position.set(offset[0], offset[1], offset[2]);
27
+ return m;
28
+ };
29
+ root.add(mkMesh("ChassisSkateboard", asm.skateboardPositions, asm.skateboardNormals, 1975339, [
30
+ 0,
31
+ 0,
32
+ 0
33
+ ]));
34
+ for (const p of asm.panels) root.add(mkMesh(`Panel_${p.partId}`, p.localPositions, p.localNormals, p.colorHex, p.anchorChassis));
35
+ const wheelNames = [
36
+ "Wheel_FL",
37
+ "Wheel_FR",
38
+ "Wheel_RL",
39
+ "Wheel_RR"
40
+ ];
41
+ asm.wheels.forEach((w, idx) => {
42
+ root.add(mkMesh(wheelNames[idx] ?? `Wheel_${idx}`, w.positions, w.normals, 1580066, w.position));
43
+ });
44
+ root.updateMatrixWorld(true);
45
+ const sz = new THREE.Box3().setFromObject(root).getSize(new THREE.Vector3());
46
+ const preset = PAPER_SHELL_PRESETS[presetId];
47
+ return {
48
+ scene: root,
49
+ lengthM: Number(Math.max(2.4, sz.z).toFixed(3)),
50
+ massKg: preset ? 1280 : 1320
51
+ };
52
+ }
53
+ async function bakeSand3dGateScene(baseScene, name, patches) {
54
+ let sourceScene = baseScene;
55
+ let rawSpecs = baseScene?.userData?.sand3dSpecs;
56
+ let extraMeta = baseScene?.userData?.sand3dExtras ?? {};
57
+ if (!rawSpecs && (!baseScene || baseScene.children.length === 0 || baseScene.userData?.proceduralDomain === "sand3d")) {
58
+ const fallback = compileSand3dAssembly(SAND3D_RECIPES[0].build());
59
+ sourceScene = fallback.scene;
60
+ rawSpecs = fallback.specs;
61
+ extraMeta = fallback.sceneExtras;
62
+ }
63
+ if (!sourceScene || !rawSpecs) return null;
64
+ const root = sourceScene.clone(true);
65
+ root.name = name || sourceScene.name || "Sand3dAsset";
66
+ const specNames = collectSpecNodeNames(rawSpecs);
67
+ ensureRootNameUnique(root, specNames);
68
+ const preserved = collectPreservedRigPatches(root, [], { localToParent: true });
69
+ const existing = collectSceneNodeNames(root, [...specNames, ...preserved.map((p) => p.nodeName)]);
70
+ const safeExplicit = disambiguateExplicitPatches(patches, existing);
71
+ const { glbBytes, bundle } = await exportStampedGateScene(root, rawSpecs, {
72
+ gateDomain: "sand3d",
73
+ ...extraMeta
74
+ }, preserved, safeExplicit);
75
+ return {
76
+ glbBytes,
77
+ bundle,
78
+ worldKind: bundle.wheels.length > 0 || bundle.propellers.length > 0 ? "vehicle" : "prop"
79
+ };
80
+ }
81
+ async function bakeSocketCraftScene(baseScene, name, massKg, powerOrThrust, patches) {
82
+ const foundThrusters = [];
83
+ baseScene.traverse((o) => {
84
+ if (o !== baseScene && /^Socket_Thruster/i.test(o.name)) foundThrusters.push(o);
85
+ });
86
+ if (foundThrusters.length === 0) return null;
87
+ baseScene.updateMatrixWorld(true);
88
+ const box = new THREE.Box3().setFromObject(baseScene);
89
+ const sz = box.isEmpty() ? new THREE.Vector3(6, 2, 8) : box.getSize(new THREE.Vector3());
90
+ const ctr = box.isEmpty() ? new THREE.Vector3(0, 1, 0) : box.getCenter(new THREE.Vector3());
91
+ const sx = Math.max(.4, sz.x), sy = Math.max(.3, sz.y), szLen = Math.max(.4, sz.z);
92
+ const totalMass = Math.max(80, massKg || 1200);
93
+ const maxThrust = Math.max(600, powerOrThrust || 12e3, Math.ceil(totalMass * 9.81 * .85));
94
+ const root = new THREE.Group();
95
+ root.name = name || "KolmoCraft";
96
+ const visualClone = cloneForNormalize(baseScene);
97
+ disambiguateSubtreeNodeNames(visualClone, /* @__PURE__ */ new Set([
98
+ "HullBody",
99
+ "Thruster_Trim_FL",
100
+ "Thruster_Trim_FR",
101
+ "Thruster_Trim_RL",
102
+ "Thruster_Trim_RR"
103
+ ]), false);
104
+ for (const c of [...visualClone.children]) root.add(c);
105
+ const hull = new THREE.Object3D();
106
+ hull.name = "HullBody";
107
+ hull.position.set(ctr.x, ctr.y, ctr.z);
108
+ root.add(hull);
109
+ const specs = [{
110
+ nodeName: "HullBody",
111
+ motion: {
112
+ isKinematic: false,
113
+ mass: totalMass,
114
+ centerOfMass: [
115
+ 0,
116
+ r4(-sy * .06),
117
+ 0
118
+ ],
119
+ inertiaDiagonal: boxInertia(totalMass, sx, sy, szLen)
120
+ },
121
+ collider: {
122
+ shape: {
123
+ type: "box",
124
+ size: [
125
+ r4(sx * .86),
126
+ r4(sy * .78),
127
+ r4(szLen * .9)
128
+ ]
129
+ },
130
+ friction: .35,
131
+ restitution: .08
132
+ }
133
+ }];
134
+ const socketThrusters = [];
135
+ root.traverse((o) => {
136
+ if (o !== root && /^Socket_Thruster/i.test(o.name)) socketThrusters.push(o);
137
+ });
138
+ let hasFore = false, hasAft = false;
139
+ socketThrusters.forEach((thr, idx) => {
140
+ const wp = thr.getWorldPosition(new THREE.Vector3());
141
+ if (wp.z > ctr.z + szLen * .12) hasFore = true;
142
+ if (wp.z < ctr.z - szLen * .12) hasAft = true;
143
+ thr.quaternion.set(0, 0, 0, 1);
144
+ specs.push({
145
+ nodeName: thr.name,
146
+ extras: {
147
+ socketId: thr.name,
148
+ ecctrlPropeller: {
149
+ maxThrust,
150
+ torqueRatio: .6,
151
+ invertTorque: idx % 2 === 1
152
+ }
153
+ },
154
+ extensions: { KOLMO_emitter: {
155
+ kind: "plume",
156
+ drive: "throttle",
157
+ size: 1
158
+ } }
159
+ });
160
+ });
161
+ const trimPads = [];
162
+ if (!hasFore) trimPads.push([
163
+ "Thruster_Trim_FL",
164
+ sx * .34,
165
+ szLen * .3,
166
+ false
167
+ ], [
168
+ "Thruster_Trim_FR",
169
+ -sx * .34,
170
+ szLen * .3,
171
+ true
172
+ ]);
173
+ if (!hasAft) trimPads.push([
174
+ "Thruster_Trim_RL",
175
+ sx * .34,
176
+ -szLen * .3,
177
+ true
178
+ ], [
179
+ "Thruster_Trim_RR",
180
+ -sx * .34,
181
+ -szLen * .3,
182
+ false
183
+ ]);
184
+ for (const [tName, dx, dz, inv] of trimPads) {
185
+ const node = new THREE.Object3D();
186
+ node.name = tName;
187
+ node.position.set(ctr.x + dx, ctr.y, ctr.z + dz);
188
+ root.add(node);
189
+ specs.push({
190
+ nodeName: tName,
191
+ extras: { ecctrlPropeller: {
192
+ maxThrust,
193
+ torqueRatio: .6,
194
+ invertTorque: inv
195
+ } }
196
+ });
197
+ }
198
+ const specNames = collectSpecNodeNames(specs);
199
+ ensureRootNameUnique(root, specNames);
200
+ const preserved = collectPreservedRigPatches(root, [], {
201
+ localToParent: true,
202
+ avoidNames: specNames
203
+ });
204
+ const existing = collectSceneNodeNames(root, [...specNames, ...preserved.map((p) => p.nodeName)]);
205
+ const safeExplicit = disambiguateExplicitPatches(patches, existing);
206
+ const { glbBytes, bundle } = await exportStampedGateScene(root, specs, {
207
+ gateDomain: "vehicle",
208
+ droneTune: {
209
+ controlMode: "VELOCITY",
210
+ maxYawRate: 2.4,
211
+ maxHorizSpeed: 44,
212
+ maxVertSpeed: 22,
213
+ maxTiltAngle: .52,
214
+ airDragFactor: .18
215
+ }
216
+ }, preserved, safeExplicit);
217
+ return {
218
+ glbBytes,
219
+ bundle,
220
+ worldKind: "vehicle"
221
+ };
222
+ }
223
+ export { bakeHingedDoorwayScene, bakeSand3dGateScene, bakeSocketCraftScene, buildProceduralPaperShellCarGroup };
224
+
225
+ //# sourceMappingURL=gateBakeHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateBakeHelpers.js","names":[],"sources":["../../src/sand3d/gateBakeHelpers.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport type { KhrAssetBundle, KhrExportNodeSpec } from \"@khr3/core\";\nimport { buildPaperShellAssembly, PAPER_SHELL_PRESETS, type PaperShellPresetId } from \"@khr3/vehicles/paper-shell\";\nimport { boxInertia, collectPreservedRigPatches, r4 } from \"../importer/khrCraftPropCompiler.js\";\nimport {\n collectSceneNodeNames,\n collectSpecNodeNames,\n disambiguateExplicitPatches,\n disambiguateSubtreeNodeNames,\n ensureRootNameUnique,\n} from \"../importer/khrNodeNameGuard.js\";\nimport { cloneForNormalize } from \"../importer/sceneSiNormalize.js\";\nimport type { KolmoAuthoredNodePatch } from \"../schema/kolmoSchema.js\";\nimport { bakeHingedDoorwayScene, exportStampedGateScene } from \"./gateDoorwayBake.js\";\nimport { SAND3D_RECIPES, compileSand3dAssembly } from \"./sand3dAssetLoader.js\";\n\nexport { bakeHingedDoorwayScene };\n\nexport function buildProceduralPaperShellCarGroup(presetId: PaperShellPresetId): {\n scene: THREE.Group;\n lengthM: number;\n massKg: number;\n} {\n const asm = buildPaperShellAssembly(presetId, \"dc-smooth\");\n const root = new THREE.Group();\n root.name = `PaperShell_${presetId}`;\n const mkMesh = (name: string, posArr: Float32Array, normArr: Float32Array, hex: number, offset: readonly [number, number, number]): THREE.Mesh => {\n const geo = new THREE.BufferGeometry();\n geo.setAttribute(\"position\", new THREE.BufferAttribute(new Float32Array(posArr), 3));\n geo.setAttribute(\"normal\", new THREE.BufferAttribute(new Float32Array(normArr), 3));\n geo.computeBoundingBox();\n const m = new THREE.Mesh(geo, new THREE.MeshStandardMaterial({ color: hex, roughness: 0.48, metalness: 0.16, flatShading: true }));\n m.name = name;\n m.position.set(offset[0], offset[1], offset[2]);\n return m;\n };\n root.add(mkMesh(\"ChassisSkateboard\", asm.skateboardPositions, asm.skateboardNormals, 0x1e242b, [0, 0, 0]));\n for (const p of asm.panels) {\n root.add(mkMesh(`Panel_${p.partId}`, p.localPositions, p.localNormals, p.colorHex, p.anchorChassis));\n }\n const wheelNames = [\"Wheel_FL\", \"Wheel_FR\", \"Wheel_RL\", \"Wheel_RR\"];\n asm.wheels.forEach((w, idx) => {\n root.add(mkMesh(wheelNames[idx] ?? `Wheel_${idx}`, w.positions, w.normals, 0x181c22, w.position));\n });\n root.updateMatrixWorld(true);\n const sz = new THREE.Box3().setFromObject(root).getSize(new THREE.Vector3());\n const preset = PAPER_SHELL_PRESETS[presetId];\n return { scene: root, lengthM: Number(Math.max(2.4, sz.z).toFixed(3)), massKg: preset ? 1280 : 1320 };\n}\n\nexport async function bakeSand3dGateScene(\n baseScene: THREE.Group | null,\n name: string,\n patches: readonly KolmoAuthoredNodePatch[],\n): Promise<{ glbBytes: Uint8Array; bundle: KhrAssetBundle; worldKind: \"vehicle\" | \"prop\" } | null> {\n let sourceScene = baseScene;\n let rawSpecs = baseScene?.userData?.sand3dSpecs as KhrExportNodeSpec[] | undefined;\n let extraMeta = (baseScene?.userData?.sand3dExtras ?? {}) as Record<string, unknown>;\n if (!rawSpecs && (!baseScene || baseScene.children.length === 0 || baseScene.userData?.proceduralDomain === \"sand3d\")) {\n const fallback = compileSand3dAssembly(SAND3D_RECIPES[0].build());\n sourceScene = fallback.scene;\n rawSpecs = fallback.specs;\n extraMeta = fallback.sceneExtras;\n }\n if (!sourceScene || !rawSpecs) return null;\n\n const root = sourceScene.clone(true);\n root.name = name || sourceScene.name || \"Sand3dAsset\";\n const specNames = collectSpecNodeNames(rawSpecs);\n ensureRootNameUnique(root, specNames);\n const preserved = collectPreservedRigPatches(root, [], { localToParent: true });\n const existing = collectSceneNodeNames(root, [...specNames, ...preserved.map((p) => p.nodeName)]);\n const safeExplicit = disambiguateExplicitPatches(patches, existing);\n const { glbBytes, bundle } = await exportStampedGateScene(root, rawSpecs, { gateDomain: \"sand3d\", ...extraMeta }, preserved, safeExplicit);\n const worldKind = bundle.wheels.length > 0 || bundle.propellers.length > 0 ? \"vehicle\" : \"prop\";\n return { glbBytes, bundle, worldKind };\n}\n\nexport async function bakeSocketCraftScene(\n baseScene: THREE.Group,\n name: string,\n massKg: number,\n powerOrThrust: number,\n patches: readonly KolmoAuthoredNodePatch[],\n): Promise<{ glbBytes: Uint8Array; bundle: KhrAssetBundle; worldKind: \"vehicle\" } | null> {\n const foundThrusters: THREE.Object3D[] = [];\n baseScene.traverse((o) => { if (o !== baseScene && /^Socket_Thruster/i.test(o.name)) foundThrusters.push(o); });\n if (foundThrusters.length === 0) return null;\n\n baseScene.updateMatrixWorld(true);\n const box = new THREE.Box3().setFromObject(baseScene);\n const sz = box.isEmpty() ? new THREE.Vector3(6, 2, 8) : box.getSize(new THREE.Vector3());\n const ctr = box.isEmpty() ? new THREE.Vector3(0, 1, 0) : box.getCenter(new THREE.Vector3());\n const sx = Math.max(0.4, sz.x), sy = Math.max(0.3, sz.y), szLen = Math.max(0.4, sz.z);\n const totalMass = Math.max(80, massKg || 1200);\n const maxThrust = Math.max(600, powerOrThrust || 12000, Math.ceil(totalMass * 9.81 * 0.85));\n\n const root = new THREE.Group();\n root.name = name || \"KolmoCraft\";\n const visualClone = cloneForNormalize(baseScene);\n const reserved = new Set<string>([\"HullBody\", \"Thruster_Trim_FL\", \"Thruster_Trim_FR\", \"Thruster_Trim_RL\", \"Thruster_Trim_RR\"]);\n disambiguateSubtreeNodeNames(visualClone, reserved, false);\n for (const c of [...visualClone.children]) root.add(c);\n\n const hull = new THREE.Object3D();\n hull.name = \"HullBody\";\n hull.position.set(ctr.x, ctr.y, ctr.z);\n root.add(hull);\n\n const specs: KhrExportNodeSpec[] = [{\n nodeName: \"HullBody\",\n motion: { isKinematic: false, mass: totalMass, centerOfMass: [0, r4(-sy * 0.06), 0], inertiaDiagonal: boxInertia(totalMass, sx, sy, szLen) },\n collider: { shape: { type: \"box\", size: [r4(sx * 0.86), r4(sy * 0.78), r4(szLen * 0.9)] }, friction: 0.35, restitution: 0.08 },\n }];\n\n const socketThrusters: THREE.Object3D[] = [];\n root.traverse((o) => { if (o !== root && /^Socket_Thruster/i.test(o.name)) socketThrusters.push(o); });\n let hasFore = false, hasAft = false;\n socketThrusters.forEach((thr, idx) => {\n const wp = thr.getWorldPosition(new THREE.Vector3());\n if (wp.z > ctr.z + szLen * 0.12) hasFore = true;\n if (wp.z < ctr.z - szLen * 0.12) hasAft = true;\n thr.quaternion.set(0, 0, 0, 1);\n specs.push({\n nodeName: thr.name,\n extras: { socketId: thr.name, ecctrlPropeller: { maxThrust, torqueRatio: 0.6, invertTorque: idx % 2 === 1 } },\n extensions: { KOLMO_emitter: { kind: \"plume\", drive: \"throttle\", size: 1 } },\n });\n });\n\n const trimPads: Array<[string, number, number, boolean]> = [];\n if (!hasFore) trimPads.push([\"Thruster_Trim_FL\", sx * 0.34, szLen * 0.3, false], [\"Thruster_Trim_FR\", -sx * 0.34, szLen * 0.3, true]);\n if (!hasAft) trimPads.push([\"Thruster_Trim_RL\", sx * 0.34, -szLen * 0.3, true], [\"Thruster_Trim_RR\", -sx * 0.34, -szLen * 0.3, false]);\n for (const [tName, dx, dz, inv] of trimPads) {\n const node = new THREE.Object3D();\n node.name = tName;\n node.position.set(ctr.x + dx, ctr.y, ctr.z + dz);\n root.add(node);\n specs.push({ nodeName: tName, extras: { ecctrlPropeller: { maxThrust, torqueRatio: 0.6, invertTorque: inv } } });\n }\n\n const specNames = collectSpecNodeNames(specs);\n ensureRootNameUnique(root, specNames);\n const preserved = collectPreservedRigPatches(root, [], { localToParent: true, avoidNames: specNames });\n const existing = collectSceneNodeNames(root, [...specNames, ...preserved.map((p) => p.nodeName)]);\n const safeExplicit = disambiguateExplicitPatches(patches, existing);\n const droneTune = { controlMode: \"VELOCITY\", maxYawRate: 2.4, maxHorizSpeed: 44, maxVertSpeed: 22, maxTiltAngle: 0.52, airDragFactor: 0.18 };\n const { glbBytes, bundle } = await exportStampedGateScene(root, specs, { gateDomain: \"vehicle\", droneTune }, preserved, safeExplicit);\n return { glbBytes, bundle, worldKind: \"vehicle\" };\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAgB,kCAAkC,UAIhD;CACE,MAAM,MAAM,wBAAwB,UAAU,WAAW;CACzD,MAAM,OAAO,IAAI,MAAM,MAAM;CAC7B,KAAK,OAAO,cAAc;CAC1B,MAAM,UAAU,MAAc,QAAsB,SAAuB,KAAa,WAA0D;EAC9I,MAAM,MAAM,IAAI,MAAM,eAAe;EACrC,IAAI,aAAa,YAAY,IAAI,MAAM,gBAAgB,IAAI,aAAa,MAAM,GAAG,CAAC,CAAC;EACnF,IAAI,aAAa,UAAU,IAAI,MAAM,gBAAgB,IAAI,aAAa,OAAO,GAAG,CAAC,CAAC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;CACrG,MAAM,WAAW,sBAAsB,MAAM,CAAC,GAAG,WAAW,GAAG,UAAU,KAAK,MAAM,EAAE,QAAQ,CAAC,CAAC;CAChG,MAAM,eAAe,4BAA4B,SAAS,QAAQ;CAElE,MAAM,EAAE,UAAU,WAAW,MAAM,uBAAuB,MAAM,OAAO;EAAE,YAAY;EAAW,WAAA;GAD5E,aAAa;GAAY,YAAY;GAAK,eAAe;GAAI,cAAc;GAAI,cAAc;GAAM,eAAe;EACtC;CAAU,GAAG,WAAW,YAAY;CACpI,OAAO;EAAE;EAAU;EAAQ,WAAW;CAAU;AACpD"}
@@ -0,0 +1,12 @@
1
+ import * as THREE from "three";
2
+ import { type KhrAssetBundle, type KhrExportNodeSpec } from "@khr3/core";
3
+ import { type KolmoAuthoredNodePatch } from "../schema/kolmoSchema.js";
4
+ export declare function exportStampedGateScene(root: THREE.Group, specs: KhrExportNodeSpec[], sceneExtras: Record<string, unknown>, preserved: readonly KolmoAuthoredNodePatch[], explicitPatches: readonly KolmoAuthoredNodePatch[]): Promise<{
5
+ glbBytes: Uint8Array;
6
+ bundle: KhrAssetBundle;
7
+ }>;
8
+ export declare function bakeHingedDoorwayScene(baseScene: THREE.Group, name: string, domain: "c12" | "prop", staticProp: boolean, massKg: number, patches: readonly KolmoAuthoredNodePatch[]): Promise<{
9
+ glbBytes: Uint8Array;
10
+ bundle: KhrAssetBundle;
11
+ worldKind: "prop";
12
+ } | null>;
@@ -0,0 +1,203 @@
1
+ import { boxInertia, collectPreservedRigPatches, r4, restoreStrippedTextures, stripUnloadedTextures } from "../importer/khrCraftPropCompiler.js";
2
+ import { collectSceneNodeNames, collectSpecNodeNames, ensureRootNameUnique } from "../importer/khrNodeNameGuard.js";
3
+ import { cloneForNormalize, isMeshObject } from "../importer/sceneSiNormalize.js";
4
+ import { disambiguateExplicitPatches, stampKolmoNodesIntoGlb } from "../schema/kolmoStamp.js";
5
+ import * as THREE from "three";
6
+ import { exportKhrGlb, loadKhrGlb } from "@khr3/core";
7
+ import { DOOR_HINGE_SPEC } from "@khr3/c12";
8
+ // src/sand3d/gateDoorwayBake.ts
9
+ var toAb = (u8) => u8.buffer.slice(u8.byteOffset, u8.byteOffset + u8.byteLength);
10
+ async function exportStampedGateScene(root, specs, sceneExtras, preserved, explicitPatches) {
11
+ const stripped = stripUnloadedTextures(root);
12
+ let raw;
13
+ try {
14
+ raw = new Uint8Array(await exportKhrGlb(root, specs, sceneExtras));
15
+ } finally {
16
+ restoreStrippedTextures(stripped);
17
+ }
18
+ const step1 = stampKolmoNodesIntoGlb(raw, preserved);
19
+ const glbBytes = new Uint8Array(stampKolmoNodesIntoGlb(step1, explicitPatches, void 0, { preserveExistingNodes: true }));
20
+ return {
21
+ glbBytes,
22
+ bundle: await loadKhrGlb(toAb(glbBytes))
23
+ };
24
+ }
25
+ async function bakeHingedDoorwayScene(baseScene, name, domain, staticProp, massKg, patches) {
26
+ let hasDoorLeaf = false;
27
+ baseScene.traverse((o) => {
28
+ if (o.userData?.doorLeafGroup === true || o.userData?.c12Role === "DoorLeaf" || /^DoorLeaf/i.test(o.name)) hasDoorLeaf = true;
29
+ });
30
+ if (!hasDoorLeaf) return null;
31
+ const cloned = cloneForNormalize(baseScene);
32
+ cloned.updateMatrixWorld(true);
33
+ const doorMeshes = [];
34
+ const frameMeshes = [];
35
+ const extrasNodes = [];
36
+ let hingeHint = null;
37
+ cloned.traverse((obj) => {
38
+ if (obj === cloned) return;
39
+ if (obj.name === "Socket_DoorHinge") hingeHint = obj.getWorldPosition(new THREE.Vector3());
40
+ const inDoor = Boolean(obj.userData?.doorLeafGroup || obj.userData?.c12Role === "DoorLeaf" || /^DoorLeaf/i.test(obj.name));
41
+ if (isMeshObject(obj) && (obj.geometry.getAttribute("position")?.count ?? 0) >= 3) {
42
+ if (inDoor) doorMeshes.push(obj);
43
+ else frameMeshes.push(obj);
44
+ } else if (obj.children.length === 0 && obj.name) extrasNodes.push(obj);
45
+ });
46
+ if (doorMeshes.length === 0) return null;
47
+ const root = new THREE.Group();
48
+ root.name = name || (domain === "c12" ? "C12Doorway" : "HingedProp");
49
+ const bodyName = domain === "c12" ? "C12Shell" : "PropBody";
50
+ const bodyGroup = new THREE.Group();
51
+ bodyGroup.name = bodyName;
52
+ root.add(bodyGroup);
53
+ const doorBox = new THREE.Box3();
54
+ for (const dm of doorMeshes) doorBox.expandByObject(dm);
55
+ const doorSize = doorBox.getSize(new THREE.Vector3());
56
+ const doorCenter = doorBox.getCenter(new THREE.Vector3());
57
+ const hingePos = hingeHint ? new THREE.Vector3(hingeHint.x, doorCenter.y, hingeHint.z) : new THREE.Vector3(doorBox.min.x + .015, doorCenter.y, doorCenter.z);
58
+ const isFixed = domain === "c12" || staticProp;
59
+ const frameMass = Math.max(12, massKg || 85);
60
+ const specs = [{
61
+ nodeName: bodyName,
62
+ motion: isFixed ? { isKinematic: true } : {
63
+ isKinematic: false,
64
+ mass: frameMass,
65
+ centerOfMass: [
66
+ 0,
67
+ r4(doorCenter.y),
68
+ 0
69
+ ],
70
+ inertiaDiagonal: boxInertia(frameMass, 1.2, 2.2, .5)
71
+ },
72
+ extras: { role: domain }
73
+ }];
74
+ frameMeshes.forEach((fm, idx) => {
75
+ const fBox = new THREE.Box3().setFromObject(fm);
76
+ const fSz = fBox.getSize(new THREE.Vector3());
77
+ const fCtr = fBox.getCenter(new THREE.Vector3());
78
+ fm.name = fm.name && fm.name !== bodyName ? `Frame_${idx}_${fm.name}` : `FrameMesh_${idx}`;
79
+ bodyGroup.add(fm);
80
+ const colNode = new THREE.Object3D();
81
+ colNode.name = `FrameCol_${idx}`;
82
+ colNode.position.copy(fCtr);
83
+ bodyGroup.add(colNode);
84
+ specs.push({
85
+ nodeName: colNode.name,
86
+ collider: {
87
+ shape: {
88
+ type: "box",
89
+ size: [
90
+ Math.max(.02, r4(fSz.x)),
91
+ Math.max(.02, r4(fSz.y)),
92
+ Math.max(.02, r4(fSz.z))
93
+ ]
94
+ },
95
+ friction: .72,
96
+ restitution: .06
97
+ }
98
+ });
99
+ });
100
+ if (frameMeshes.length === 0) {
101
+ const post = new THREE.Object3D();
102
+ post.name = "FrameCol_HingePost";
103
+ post.position.copy(hingePos);
104
+ bodyGroup.add(post);
105
+ specs.push({
106
+ nodeName: post.name,
107
+ collider: {
108
+ shape: {
109
+ type: "box",
110
+ size: [
111
+ .05,
112
+ Math.max(.2, r4(doorSize.y)),
113
+ .05
114
+ ]
115
+ },
116
+ friction: .72,
117
+ restitution: .06
118
+ }
119
+ });
120
+ }
121
+ for (const en of extrasNodes) {
122
+ const cloneEmpty = en.clone();
123
+ if (cloneEmpty.name === "DoorLeaf" || cloneEmpty.name === bodyName) cloneEmpty.name = `Socket_${cloneEmpty.name}`;
124
+ bodyGroup.add(cloneEmpty);
125
+ }
126
+ const hingeAnchor = new THREE.Object3D();
127
+ hingeAnchor.name = "DoorHinge_Anchor";
128
+ hingeAnchor.position.copy(hingePos);
129
+ bodyGroup.add(hingeAnchor);
130
+ const doorGroup = new THREE.Group();
131
+ doorGroup.name = "DoorLeaf";
132
+ doorGroup.position.copy(hingePos);
133
+ doorMeshes.forEach((dm, idx) => {
134
+ dm.name = `DoorLeaf_Mesh_${idx}`;
135
+ dm.position.sub(hingePos);
136
+ doorGroup.add(dm);
137
+ });
138
+ const relCom = [
139
+ r4(doorCenter.x - hingePos.x),
140
+ r4(doorCenter.y - hingePos.y),
141
+ r4(doorCenter.z - hingePos.z)
142
+ ];
143
+ const leafCol = new THREE.Object3D();
144
+ leafCol.name = "DoorLeaf_Collider";
145
+ leafCol.position.set(relCom[0], relCom[1], relCom[2]);
146
+ doorGroup.add(leafCol);
147
+ root.add(doorGroup);
148
+ specs.push({
149
+ nodeName: "DoorLeaf_Collider",
150
+ collider: {
151
+ shape: {
152
+ type: "box",
153
+ size: [
154
+ Math.max(.04, r4(doorSize.x * .94)),
155
+ Math.max(.04, r4(doorSize.y * .96)),
156
+ Math.max(.025, r4(doorSize.z))
157
+ ]
158
+ },
159
+ friction: .52,
160
+ restitution: .05
161
+ }
162
+ }, {
163
+ nodeName: "DoorLeaf",
164
+ motion: {
165
+ isKinematic: false,
166
+ mass: DOOR_HINGE_SPEC.massKg,
167
+ centerOfMass: relCom,
168
+ inertiaDiagonal: boxInertia(DOOR_HINGE_SPEC.massKg, Math.max(.1, doorSize.x), Math.max(.1, doorSize.y), Math.max(.04, doorSize.z))
169
+ },
170
+ joint: {
171
+ connectedNodeName: "DoorHinge_Anchor",
172
+ kind: "revolute",
173
+ axis: [...DOOR_HINGE_SPEC.axisLocal],
174
+ limits: [...DOOR_HINGE_SPEC.limitsRad],
175
+ enableCollision: false,
176
+ drive: {
177
+ type: "angular",
178
+ mode: "acceleration",
179
+ positionTarget: 0,
180
+ stiffness: DOOR_HINGE_SPEC.stiffness,
181
+ damping: DOOR_HINGE_SPEC.damping
182
+ }
183
+ },
184
+ extras: { role: "door" }
185
+ });
186
+ const specNames = collectSpecNodeNames(specs);
187
+ ensureRootNameUnique(root, specNames);
188
+ const preserved = collectPreservedRigPatches(root, [], {
189
+ localToParent: true,
190
+ avoidNames: specNames
191
+ });
192
+ const existing = collectSceneNodeNames(root, [...specNames, ...preserved.map((p) => p.nodeName)]);
193
+ const safeExplicit = disambiguateExplicitPatches(patches, existing);
194
+ const { glbBytes, bundle } = await exportStampedGateScene(root, specs, { gateDomain: domain }, preserved, safeExplicit);
195
+ return {
196
+ glbBytes,
197
+ bundle,
198
+ worldKind: "prop"
199
+ };
200
+ }
201
+ export { bakeHingedDoorwayScene, exportStampedGateScene };
202
+
203
+ //# sourceMappingURL=gateDoorwayBake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateDoorwayBake.js","names":[],"sources":["../../src/sand3d/gateDoorwayBake.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { DOOR_HINGE_SPEC } from \"@khr3/c12\";\nimport { exportKhrGlb, loadKhrGlb, type KhrAssetBundle, type KhrExportNodeSpec } from \"@khr3/core\";\nimport { boxInertia, collectPreservedRigPatches, r4, restoreStrippedTextures, stripUnloadedTextures } from \"../importer/khrCraftPropCompiler.js\";\nimport {\n collectSceneNodeNames,\n collectSpecNodeNames,\n disambiguateExplicitPatches,\n ensureRootNameUnique,\n} from \"../importer/khrNodeNameGuard.js\";\nimport { cloneForNormalize, isMeshObject } from \"../importer/sceneSiNormalize.js\";\nimport { stampKolmoNodesIntoGlb, type KolmoAuthoredNodePatch } from \"../schema/kolmoSchema.js\";\n\nconst toAb = (u8: Uint8Array): ArrayBuffer => u8.buffer.slice(u8.byteOffset, u8.byteOffset + u8.byteLength) as ArrayBuffer;\n\nexport async function exportStampedGateScene(\n root: THREE.Group,\n specs: KhrExportNodeSpec[],\n sceneExtras: Record<string, unknown>,\n preserved: readonly KolmoAuthoredNodePatch[],\n explicitPatches: readonly KolmoAuthoredNodePatch[],\n): Promise<{ glbBytes: Uint8Array; bundle: KhrAssetBundle }> {\n const stripped = stripUnloadedTextures(root);\n let raw: Uint8Array;\n try {\n raw = new Uint8Array(await exportKhrGlb(root, specs, sceneExtras));\n } finally {\n restoreStrippedTextures(stripped);\n }\n const step1 = stampKolmoNodesIntoGlb(raw, preserved);\n const glbBytes = new Uint8Array(stampKolmoNodesIntoGlb(step1, explicitPatches, undefined, { preserveExistingNodes: true }));\n return { glbBytes, bundle: await loadKhrGlb(toAb(glbBytes)) };\n}\n\nexport async function bakeHingedDoorwayScene(\n baseScene: THREE.Group,\n name: string,\n domain: \"c12\" | \"prop\",\n staticProp: boolean,\n massKg: number,\n patches: readonly KolmoAuthoredNodePatch[],\n): Promise<{ glbBytes: Uint8Array; bundle: KhrAssetBundle; worldKind: \"prop\" } | null> {\n let hasDoorLeaf = false;\n baseScene.traverse((o) => {\n if (o.userData?.doorLeafGroup === true || o.userData?.c12Role === \"DoorLeaf\" || /^DoorLeaf/i.test(o.name)) hasDoorLeaf = true;\n });\n if (!hasDoorLeaf) return null;\n\n const cloned = cloneForNormalize(baseScene);\n cloned.updateMatrixWorld(true);\n const doorMeshes: THREE.Mesh[] = [];\n const frameMeshes: THREE.Mesh[] = [];\n const extrasNodes: THREE.Object3D[] = [];\n let hingeHint: THREE.Vector3 | null = null;\n\n cloned.traverse((obj) => {\n if (obj === cloned) return;\n if (obj.name === \"Socket_DoorHinge\") hingeHint = obj.getWorldPosition(new THREE.Vector3());\n const inDoor = Boolean(obj.userData?.doorLeafGroup || obj.userData?.c12Role === \"DoorLeaf\" || /^DoorLeaf/i.test(obj.name));\n if (isMeshObject(obj) && (obj.geometry.getAttribute(\"position\")?.count ?? 0) >= 3) {\n if (inDoor) doorMeshes.push(obj);\n else frameMeshes.push(obj);\n } else if (obj.children.length === 0 && obj.name) {\n extrasNodes.push(obj);\n }\n });\n if (doorMeshes.length === 0) return null;\n\n const root = new THREE.Group();\n root.name = name || (domain === \"c12\" ? \"C12Doorway\" : \"HingedProp\");\n const bodyName = domain === \"c12\" ? \"C12Shell\" : \"PropBody\";\n const bodyGroup = new THREE.Group();\n bodyGroup.name = bodyName;\n root.add(bodyGroup);\n\n const doorBox = new THREE.Box3();\n for (const dm of doorMeshes) doorBox.expandByObject(dm);\n const doorSize = doorBox.getSize(new THREE.Vector3());\n const doorCenter = doorBox.getCenter(new THREE.Vector3());\n const hingePos = hingeHint\n ? new THREE.Vector3((hingeHint as THREE.Vector3).x, doorCenter.y, (hingeHint as THREE.Vector3).z)\n : new THREE.Vector3(doorBox.min.x + 0.015, doorCenter.y, doorCenter.z);\n\n const isFixed = domain === \"c12\" || staticProp;\n const frameMass = Math.max(12, massKg || 85);\n const specs: KhrExportNodeSpec[] = [{\n nodeName: bodyName,\n motion: isFixed\n ? { isKinematic: true }\n : { isKinematic: false, mass: frameMass, centerOfMass: [0, r4(doorCenter.y), 0], inertiaDiagonal: boxInertia(frameMass, 1.2, 2.2, 0.5) },\n extras: { role: domain },\n }];\n\n frameMeshes.forEach((fm, idx) => {\n const fBox = new THREE.Box3().setFromObject(fm);\n const fSz = fBox.getSize(new THREE.Vector3());\n const fCtr = fBox.getCenter(new THREE.Vector3());\n fm.name = fm.name && fm.name !== bodyName ? `Frame_${idx}_${fm.name}` : `FrameMesh_${idx}`;\n bodyGroup.add(fm);\n const colNode = new THREE.Object3D();\n colNode.name = `FrameCol_${idx}`;\n colNode.position.copy(fCtr);\n bodyGroup.add(colNode);\n specs.push({\n nodeName: colNode.name,\n collider: { shape: { type: \"box\", size: [Math.max(0.02, r4(fSz.x)), Math.max(0.02, r4(fSz.y)), Math.max(0.02, r4(fSz.z))] }, friction: 0.72, restitution: 0.06 },\n });\n });\n if (frameMeshes.length === 0) {\n const post = new THREE.Object3D();\n post.name = \"FrameCol_HingePost\";\n post.position.copy(hingePos);\n bodyGroup.add(post);\n specs.push({ nodeName: post.name, collider: { shape: { type: \"box\", size: [0.05, Math.max(0.2, r4(doorSize.y)), 0.05] }, friction: 0.72, restitution: 0.06 } });\n }\n for (const en of extrasNodes) {\n const cloneEmpty = en.clone();\n if (cloneEmpty.name === \"DoorLeaf\" || cloneEmpty.name === bodyName) cloneEmpty.name = `Socket_${cloneEmpty.name}`;\n bodyGroup.add(cloneEmpty);\n }\n\n const hingeAnchor = new THREE.Object3D();\n hingeAnchor.name = \"DoorHinge_Anchor\";\n hingeAnchor.position.copy(hingePos);\n bodyGroup.add(hingeAnchor);\n\n const doorGroup = new THREE.Group();\n doorGroup.name = \"DoorLeaf\";\n doorGroup.position.copy(hingePos);\n doorMeshes.forEach((dm, idx) => {\n dm.name = `DoorLeaf_Mesh_${idx}`;\n dm.position.sub(hingePos);\n doorGroup.add(dm);\n });\n const relCom: [number, number, number] = [r4(doorCenter.x - hingePos.x), r4(doorCenter.y - hingePos.y), r4(doorCenter.z - hingePos.z)];\n const leafCol = new THREE.Object3D();\n leafCol.name = \"DoorLeaf_Collider\";\n leafCol.position.set(relCom[0], relCom[1], relCom[2]);\n doorGroup.add(leafCol);\n root.add(doorGroup);\n\n specs.push(\n {\n nodeName: \"DoorLeaf_Collider\",\n collider: { shape: { type: \"box\", size: [Math.max(0.04, r4(doorSize.x * 0.94)), Math.max(0.04, r4(doorSize.y * 0.96)), Math.max(0.025, r4(doorSize.z))] }, friction: 0.52, restitution: 0.05 },\n },\n {\n nodeName: \"DoorLeaf\",\n motion: {\n isKinematic: false,\n mass: DOOR_HINGE_SPEC.massKg,\n centerOfMass: relCom,\n inertiaDiagonal: boxInertia(DOOR_HINGE_SPEC.massKg, Math.max(0.1, doorSize.x), Math.max(0.1, doorSize.y), Math.max(0.04, doorSize.z)),\n },\n joint: {\n connectedNodeName: \"DoorHinge_Anchor\",\n kind: \"revolute\",\n axis: [...DOOR_HINGE_SPEC.axisLocal] as [number, number, number],\n limits: [...DOOR_HINGE_SPEC.limitsRad] as [number, number],\n enableCollision: false,\n drive: { type: \"angular\", mode: \"acceleration\", positionTarget: 0, stiffness: DOOR_HINGE_SPEC.stiffness, damping: DOOR_HINGE_SPEC.damping },\n },\n extras: { role: \"door\" },\n },\n );\n\n const specNames = collectSpecNodeNames(specs);\n ensureRootNameUnique(root, specNames);\n const preserved = collectPreservedRigPatches(root, [], { localToParent: true, avoidNames: specNames });\n const existing = collectSceneNodeNames(root, [...specNames, ...preserved.map((p) => p.nodeName)]);\n const safeExplicit = disambiguateExplicitPatches(patches, existing);\n const { glbBytes, bundle } = await exportStampedGateScene(root, specs, { gateDomain: domain }, preserved, safeExplicit);\n return { glbBytes, bundle, worldKind: \"prop\" };\n}\n"],"mappings":";;;;;;;;AAaA,IAAM,QAAQ,OAAgC,GAAG,OAAO,MAAM,GAAG,YAAY,GAAG,aAAa,GAAG,UAAU;AAE1G,eAAsB,uBAClB,MACA,OACA,aACA,WACA,iBACyD;CACzD,MAAM,WAAW,sBAAsB,IAAI;CAC3C,IAAI;CACJ,IAAI;EACA,MAAM,IAAI,WAAW,MAAM,aAAa,MAAM,OAAO,WAAW,CAAC;CACrE,UAAU;EACN,wBAAwB,QAAQ;CACpC;CACA,MAAM,QAAQ,uBAAuB,KAAK,SAAS;CACnD,MAAM,WAAW,IAAI,WAAW,uBAAuB,OAAO,iBAAiB,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EAAU;EAAQ,WAAW;CAAO;AACjD"}
@@ -0,0 +1,3 @@
1
+ export { SAND3D_RECIPES, SAND3D_RECIPE_MAP, buildSand3dRecipe, compileSand3dAssembly, compileSand3dRecipeGlb, detectSand3dBytes, exportCompiledSand3dWithKolmo, exportSand3dGlb, findSand3dRecipe, ingestSand3dOrGlb, isSand3dFileName, isSupportedCadImportFileName, loadSand3dBundle, measureNaturalSceneSpanM, parseSand3dSource, resolveSand3dAssembly, s3d, type CompiledSand3dAssembly, type IngestedSand3dAsset, type Sand3dAssembly, type Sand3dRecipe, type Sand3dRecipeId, } from "./sand3dAssetLoader.js";
2
+ export { KolmoSand3D, KolmoSand3D as Sand3D, type KolmoSand3DProps, } from "./KolmoSand3D.js";
3
+ export { Sand3dWorkshopSection, type Sand3dWorkshopSectionProps, } from "./Sand3dWorkshopSection.js";
@@ -0,0 +1,4 @@
1
+ import { SAND3D_RECIPES, SAND3D_RECIPE_MAP, buildSand3dRecipe, compileSand3dAssembly, compileSand3dRecipeGlb, detectSand3dBytes, exportCompiledSand3dWithKolmo, exportSand3dGlb, findSand3dRecipe, ingestSand3dOrGlb, isSand3dFileName, isSupportedCadImportFileName, loadSand3dBundle, measureNaturalSceneSpanM, parseSand3dSource, resolveSand3dAssembly, s3d } from "./sand3dAssetLoader.js";
2
+ import { KolmoSand3D } from "./KolmoSand3D.js";
3
+ import { Sand3dWorkshopSection } from "./Sand3dWorkshopSection.js";
4
+ export { KolmoSand3D, SAND3D_RECIPES, SAND3D_RECIPE_MAP, KolmoSand3D as Sand3D, Sand3dWorkshopSection, buildSand3dRecipe, compileSand3dAssembly, compileSand3dRecipeGlb, detectSand3dBytes, exportCompiledSand3dWithKolmo, exportSand3dGlb, findSand3dRecipe, ingestSand3dOrGlb, isSand3dFileName, isSupportedCadImportFileName, loadSand3dBundle, measureNaturalSceneSpanM, parseSand3dSource, resolveSand3dAssembly, s3d };