@babylonjs/mcp-servers 9.14.0 → 9.16.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.
@@ -96,7 +96,7 @@ data: ${JSON.stringify({reason:r})}
96
96
  Inputs:`);for(const u of n.inputs){const l=u.targetBlockId!==void 0?` \u2190 connected to [${u.targetBlockId}].${u.targetConnectionName}`:" (unconnected)";a.push(` \u2022 ${u.name}${l}`)}a.push(`
97
97
  Outputs:`);for(const u of n.outputs){const l=[];for(const p of o.blocks)for(const m of p.inputs)m.targetBlockId===r&&m.targetConnectionName===u.name&&l.push(`[${p.id}] ${p.name}.${m.name}`);const d=l.length>0?` \u2192 ${l.join(", ")}`:" (unconnected)";a.push(` \u2022 ${u.name}${d}`)}const s=new Set(["customType","id","name","inputs","outputs"]),c=Object.entries(n).filter(([u])=>!s.has(u));if(c.length>0){a.push(`
98
98
  Properties:`);for(const[u,l]of c)a.push(` ${u}: ${JSON.stringify(l)}`)}return a.join(`
99
- `)}exportJSON(t){const r=this._geometries.get(t);if(r){for(const o of r.blocks){o.customType==="BABYLON.GeometryInputBlock"&&(this._normaliseInputBlockValue(o),this._ensureDefaultValue(o));const n=o.customType.replace("BABYLON.",""),i=En[n];if(i?.defaultSerializedProperties)for(const[s,c]of Object.entries(i.defaultSerializedProperties))o[s]===void 0&&(o[s]=c);const a=Er[n];if(a)for(const[s,c]of Object.entries(a))typeof o[s]=="string"&&(o[s]=c[o[s]]??o[s])}return this._layoutGraph(r),JSON.stringify(r,null,2)}}static COL_WIDTH=340;static ROW_HEIGHT=180;_layoutGraph(t){const r=t.blocks;if(r.length===0)return;const o=new Map;for(const g of r)o.set(g.id,g);const n=new Map,i=new Map;for(const g of r)n.set(g.id,new Set),i.set(g.id,new Set);for(const g of r)for(const v of g.inputs)v.targetBlockId!==void 0&&(n.get(g.id).add(v.targetBlockId),i.get(v.targetBlockId)?.add(g.id));const a=new Map,s=[];if(t.outputNodeId>=0&&o.has(t.outputNodeId))a.set(t.outputNodeId,0),s.push(t.outputNodeId);else for(const g of r)g.customType==="BABYLON.GeometryOutputBlock"&&(a.set(g.id,0),s.push(g.id));s.length===0&&r.length>0&&(a.set(r[r.length-1].id,0),s.push(r[r.length-1].id));let c=0;for(;c<s.length;){const g=s[c++],v=a.get(g);for(const y of n.get(g)??[]){const b=a.get(y);(b===void 0||v+1>b)&&(a.set(y,v+1),s.push(y))}}const u=Math.max(0,...a.values());for(const g of r)a.has(g.id)||a.set(g.id,u+1);const l=Math.max(0,...a.values()),d=new Map;for(const[g,v]of a)d.set(g,l-v);const p=new Map;for(const g of r){const v=d.get(g.id);p.has(v)||p.set(v,[]),p.get(v).push(g.id)}const m=[...p.keys()].sort((g,v)=>v-g),h=new Map;for(const g of m){const v=p.get(g);if(g===m[0])v.forEach((y,b)=>h.set(y,b));else{const y=new Map;for(const b of v){const I=i.get(b),P=[];for(const M of I){const G=h.get(M);G!==void 0&&P.push(G)}P.length>0?y.set(b,P.reduce((M,G)=>M+G,0)/P.length):y.set(b,9999)}v.sort((b,I)=>y.get(b)-y.get(I)),v.forEach((b,I)=>h.set(b,I))}}const $=[];for(const g of r){const v=d.get(g.id),y=h.get(g.id);$.push({blockId:g.id,x:v*bi.COL_WIDTH,y:y*bi.ROW_HEIGHT})}t.editorData?t.editorData.locations=$:t.editorData={locations:$}}importJSON(t,r){try{const o=Px(r);this._geometries.set(t,o);const n=o.blocks.reduce((i,a)=>Math.max(i,a.id),0);return this._nextId.set(t,n+1),this._nextX.set(t,o.blocks.length*280),"OK"}catch(o){return o.message}}setBlockProperties(t,r,o){const n=this._geometries.get(t);if(!n)return`Geometry "${t}" not found.`;const i=n.blocks.find(s=>s.id===r);if(!i)return`Block ${r} not found.`;const a=i.customType.replace("BABYLON.","");for(const[s,c]of Object.entries(o))if(a==="GeometryInputBlock"&&s==="type"&&typeof c=="string")i.type=de[c]??c;else if(a==="GeometryInputBlock"&&s==="contextualValue"&&typeof c=="string"){const u=Ie[c]??c;i.contextualValue=u,typeof u=="number"&&u!==Ie.None&&$i[u]!==void 0&&(i.type=$i[u])}else typeof c=="string"&&Er[a]?.[s]?i[s]=Er[a][s][c]??c:i[s]=c;return a==="GeometryInputBlock"&&(this._normaliseInputBlockValue(i),this._ensureDefaultValue(i)),"OK"}validateGeometry(t){const r=this._geometries.get(t);if(!r)return[`Geometry "${t}" not found.`];const o=[];r.blocks.some(i=>i.customType==="BABYLON.GeometryOutputBlock")||o.push("ERROR: Missing GeometryOutputBlock \u2014 every geometry graph needs exactly one."),r.outputNodeId<0?o.push("ERROR: outputNodeId is not set. There should be a GeometryOutputBlock."):r.blocks.find(i=>i.id===r.outputNodeId)||o.push(`ERROR: outputNodeId references block ${r.outputNodeId} which does not exist.`);for(const i of r.blocks){const a=i.customType.replace("BABYLON.",""),s=Object.values(En).find(c=>c.className===a);if(s)for(const c of i.inputs){const u=s.inputs.find(l=>l.name===c.name);c.targetBlockId===void 0&&u&&!u.isOptional&&o.push(`WARNING: Block [${i.id}] "${i.name}" has required input "${c.name}" that is not connected.`)}}for(const i of r.blocks)for(const a of i.inputs)if(a.targetBlockId!==void 0){const s=r.blocks.find(c=>c.id===a.targetBlockId);s?s.outputs.find(c=>c.name===a.targetConnectionName)||o.push(`WARNING: Block [${i.id}] "${i.name}" input "${a.name}" references output "${a.targetConnectionName}" which doesn't exist on block [${s.id}].`):o.push(`ERROR: Block [${i.id}] "${i.name}" input "${a.name}" references non-existent block ${a.targetBlockId}.`)}for(const i of r.blocks){if(i.customType!=="BABYLON.GeometryInputBlock")continue;const a=i.contextualValue,s=i.value!==void 0;(a===void 0||a===Ie.None)&&!s&&o.push(`WARNING: GeometryInputBlock [${i.id}] "${i.name}" has no contextual value and no constant value \u2014 it provides no data.`)}for(const i of r.blocks){if(i.customType==="BABYLON.GeometryOutputBlock"||i.customType==="BABYLON.GeometryInputBlock")continue;const a=i.inputs.some(c=>c.targetBlockId!==void 0),s=r.blocks.some(c=>c.inputs.some(u=>u.targetBlockId===i.id));!a&&!s&&o.push(`WARNING: Block [${i.id}] "${i.name}" (${i.customType.replace("BABYLON.","")}) has no connections \u2014 it is an orphan and does nothing.`)}return o.length===0&&o.push("No issues found \u2014 graph looks valid."),o}}const Kx="https://cdn.babylonjs.com",Wx={havok:"havok/HavokPhysics_umd.js",ammo:"ammo/ammo.js",recast:"recast.js"},ou="https://snippet.babylonjs.com";async function Yx(e,t=ou){let r=e.replace(/#/g,"/");r.includes("/")||(r+="/0");const o=`${t}/${r}`,n=await fetch(o);if(!n.ok)throw new Error(`Failed to fetch snippet "${e}": ${n.status} ${n.statusText}`);return await n.json()}const Xx=[["nodeMaterial","nodeMaterial"],["nodeGeometry","nodeGeometry"],["nodeRenderGraph","nodeRenderGraph"],["nodeParticle","nodeParticle"],["gui","gui"],["encodedGui","gui"],["animations","animation"],["animation","animation"],["particleSystem","particleSystem"],["spriteManager","spriteManager"],["shaderMaterial","shaderMaterial"]];function Qx(e){const t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r.buffer}function Ev(e){const t=new Uint8Array(Qx(e));return new TextDecoder("utf-8").decode(t)}function eT(e){if(e.files&&typeof e.files=="object"&&e.v!==void 0||typeof e.code=="string")return"playground";for(const[t,r]of Xx)if(t in e)return r;return"unknown"}function tT(e,t,r,o){let n;switch(t){case"gui":{typeof e.encodedGui=="string"?n=JSON.parse(Ev(e.encodedGui)):n=typeof e.gui=="string"?JSON.parse(e.gui):e.gui;break}case"animation":{typeof e.animations=="string"?n=JSON.parse(e.animations):e.animations!==void 0?n=e.animations:typeof e.animation=="string"?n=JSON.parse(e.animation):n=e.animation;break}default:{const a=e[t];n=typeof a=="string"?JSON.parse(a):a;break}}return{snippetId:r,type:t,metadata:o,data:n,load:i=>i?i(n):n}}let iu=null;async function nT(){return await import("monaco-editor/esm/vs/language/typescript/lib/typescriptServices")}async function rT(){return iu||(iu=nT().then(e=>e.typescript)),await iu}async function oT(e,t){const r=await rT();return r.transpileModule(e,{compilerOptions:{target:r.ScriptTarget.ESNext,module:r.ModuleKind.ESNext,jsx:t.endsWith(".tsx")?r.JsxEmit.ReactJSX:void 0,esModuleInterop:!1,allowJs:!0,sourceMap:!1,experimentalDecorators:!0,emitDecoratorMetadata:!1,isolatedModules:!0,strict:!1,allowUmdGlobalAccess:!0},fileName:t}).outputText}async function iT(e,t){const r={},o=[];for(const[n,i]of Object.entries(e))if(/\.tsx?$/i.test(n)){const a=n.replace(/\.tsx?$/i,".js");o.push((async()=>{r[a]=await Promise.resolve(t(i,n))})())}else r[n]=i;return await Promise.all(o),r}const zv=["delayCreateScene","delayLoadScene","createScene","CreateScene","createscene"];function aT(e){if(e.includes("class Playground"))return"TS";if(zv.some(o=>e.includes(o))||!e)return"JS";const t=[/\binterface\s+[A-Za-z_]\w*/m,/\benum\s+[A-Za-z_]\w*/m,/\btype\s+[A-Za-z_]\w*\s*=/m,/\bimplements\s+[A-Za-z_]/m,/\breadonly\b/m,/\bpublic\b|\bprivate\b|\bprotected\b/m,/\babstract\s+class\b/m,/\bas\s+const\b/m,/\bimport\s+type\s+/m],r=/[:]\s*[A-Za-z_$][\w$.<>,\s?\\[\]|&]*\b(?![:=])/m.test(e);return t.some(o=>o.test(e))||r?"TS":"JS"}function sT(e,t){let r=e;if(t==="JS"){const n=r.search(/(?:var|let|const|function)\s+(?:createScene|delayCreateScene|delayLoadScene|createEngine|CreateScene)\b/),i=n>0?r.slice(0,n):"";i&&(r=i.replace(/^[^\S\n]*(?:var|let|const)\s+canvas\s*=\s*document\.getElementById\s*\([^)]*\)\s*;?[^\S\n]*$/gm,"// [snippet-loader] canvas provided by host").replace(/^[^\S\n]*(?:var|let|const)\s+engine\s*=\s*new\s+BABYLON\.\w*Engine\b[^;]*;?[^\S\n]*$/gm,"// [snippet-loader] engine provided by host")+r.slice(n))}const o=t==="TS"?"Playground":zv.find(n=>r.includes(n))??"createScene";return r+=`
99
+ `)}exportJSON(t){const r=this._geometries.get(t);if(r){for(const o of r.blocks){o.customType==="BABYLON.GeometryInputBlock"&&(this._normaliseInputBlockValue(o),this._ensureDefaultValue(o));const n=o.customType.replace("BABYLON.",""),i=En[n];if(i?.defaultSerializedProperties)for(const[s,c]of Object.entries(i.defaultSerializedProperties))o[s]===void 0&&(o[s]=c);const a=Er[n];if(a)for(const[s,c]of Object.entries(a))typeof o[s]=="string"&&(o[s]=c[o[s]]??o[s])}return this._layoutGraph(r),JSON.stringify(r,null,2)}}static COL_WIDTH=340;static ROW_HEIGHT=180;_layoutGraph(t){const r=t.blocks;if(r.length===0)return;const o=new Map;for(const g of r)o.set(g.id,g);const n=new Map,i=new Map;for(const g of r)n.set(g.id,new Set),i.set(g.id,new Set);for(const g of r)for(const v of g.inputs)v.targetBlockId!==void 0&&(n.get(g.id).add(v.targetBlockId),i.get(v.targetBlockId)?.add(g.id));const a=new Map,s=[];if(t.outputNodeId>=0&&o.has(t.outputNodeId))a.set(t.outputNodeId,0),s.push(t.outputNodeId);else for(const g of r)g.customType==="BABYLON.GeometryOutputBlock"&&(a.set(g.id,0),s.push(g.id));s.length===0&&r.length>0&&(a.set(r[r.length-1].id,0),s.push(r[r.length-1].id));let c=0;for(;c<s.length;){const g=s[c++],v=a.get(g);for(const y of n.get(g)??[]){const b=a.get(y);(b===void 0||v+1>b)&&(a.set(y,v+1),s.push(y))}}const u=Math.max(0,...a.values());for(const g of r)a.has(g.id)||a.set(g.id,u+1);const l=Math.max(0,...a.values()),d=new Map;for(const[g,v]of a)d.set(g,l-v);const p=new Map;for(const g of r){const v=d.get(g.id);p.has(v)||p.set(v,[]),p.get(v).push(g.id)}const m=[...p.keys()].sort((g,v)=>v-g),h=new Map;for(const g of m){const v=p.get(g);if(g===m[0])v.forEach((y,b)=>h.set(y,b));else{const y=new Map;for(const b of v){const I=i.get(b),P=[];for(const M of I){const G=h.get(M);G!==void 0&&P.push(G)}P.length>0?y.set(b,P.reduce((M,G)=>M+G,0)/P.length):y.set(b,9999)}v.sort((b,I)=>y.get(b)-y.get(I)),v.forEach((b,I)=>h.set(b,I))}}const $=[];for(const g of r){const v=d.get(g.id),y=h.get(g.id);$.push({blockId:g.id,x:v*bi.COL_WIDTH,y:y*bi.ROW_HEIGHT})}t.editorData?t.editorData.locations=$:t.editorData={locations:$}}importJSON(t,r){try{const o=Px(r);this._geometries.set(t,o);const n=o.blocks.reduce((i,a)=>Math.max(i,a.id),0);return this._nextId.set(t,n+1),this._nextX.set(t,o.blocks.length*280),"OK"}catch(o){return o.message}}setBlockProperties(t,r,o){const n=this._geometries.get(t);if(!n)return`Geometry "${t}" not found.`;const i=n.blocks.find(s=>s.id===r);if(!i)return`Block ${r} not found.`;const a=i.customType.replace("BABYLON.","");for(const[s,c]of Object.entries(o))if(a==="GeometryInputBlock"&&s==="type"&&typeof c=="string")i.type=de[c]??c;else if(a==="GeometryInputBlock"&&s==="contextualValue"&&typeof c=="string"){const u=Ie[c]??c;i.contextualValue=u,typeof u=="number"&&u!==Ie.None&&$i[u]!==void 0&&(i.type=$i[u])}else typeof c=="string"&&Er[a]?.[s]?i[s]=Er[a][s][c]??c:i[s]=c;return a==="GeometryInputBlock"&&(this._normaliseInputBlockValue(i),this._ensureDefaultValue(i)),"OK"}validateGeometry(t){const r=this._geometries.get(t);if(!r)return[`Geometry "${t}" not found.`];const o=[];r.blocks.some(i=>i.customType==="BABYLON.GeometryOutputBlock")||o.push("ERROR: Missing GeometryOutputBlock \u2014 every geometry graph needs exactly one."),r.outputNodeId<0?o.push("ERROR: outputNodeId is not set. There should be a GeometryOutputBlock."):r.blocks.find(i=>i.id===r.outputNodeId)||o.push(`ERROR: outputNodeId references block ${r.outputNodeId} which does not exist.`);for(const i of r.blocks){const a=i.customType.replace("BABYLON.",""),s=Object.values(En).find(c=>c.className===a);if(s)for(const c of i.inputs){const u=s.inputs.find(l=>l.name===c.name);c.targetBlockId===void 0&&u&&!u.isOptional&&o.push(`WARNING: Block [${i.id}] "${i.name}" has required input "${c.name}" that is not connected.`)}}for(const i of r.blocks)for(const a of i.inputs)if(a.targetBlockId!==void 0){const s=r.blocks.find(c=>c.id===a.targetBlockId);s?s.outputs.find(c=>c.name===a.targetConnectionName)||o.push(`WARNING: Block [${i.id}] "${i.name}" input "${a.name}" references output "${a.targetConnectionName}" which doesn't exist on block [${s.id}].`):o.push(`ERROR: Block [${i.id}] "${i.name}" input "${a.name}" references non-existent block ${a.targetBlockId}.`)}for(const i of r.blocks){if(i.customType!=="BABYLON.GeometryInputBlock")continue;const a=i.contextualValue,s=i.value!==void 0;(a===void 0||a===Ie.None)&&!s&&o.push(`WARNING: GeometryInputBlock [${i.id}] "${i.name}" has no contextual value and no constant value \u2014 it provides no data.`)}for(const i of r.blocks){if(i.customType==="BABYLON.GeometryOutputBlock"||i.customType==="BABYLON.GeometryInputBlock")continue;const a=i.inputs.some(c=>c.targetBlockId!==void 0),s=r.blocks.some(c=>c.inputs.some(u=>u.targetBlockId===i.id));!a&&!s&&o.push(`WARNING: Block [${i.id}] "${i.name}" (${i.customType.replace("BABYLON.","")}) has no connections \u2014 it is an orphan and does nothing.`)}return o.length===0&&o.push("No issues found \u2014 graph looks valid."),o}}const Kx="https://cdn.babylonjs.com",Wx={havok:"havok/HavokPhysics_umd.js",ammo:"ammo/ammo.js",recast:"recast.js"},ou="https://snippet.babylonjs.com";async function Yx(e,t=ou){let r=e.replace(/#/g,"/");r.includes("/")||(r+="/0");const o=`${t}/${r}`,n=await fetch(o);if(!n.ok)throw new Error(`Failed to fetch snippet "${e}": ${n.status} ${n.statusText}`);return await n.json()}const Xx=[["nodeMaterial","nodeMaterial"],["nodeGeometry","nodeGeometry"],["nodeRenderGraph","nodeRenderGraph"],["nodeParticle","nodeParticle"],["gui","gui"],["encodedGui","gui"],["animations","animation"],["animation","animation"],["particleSystem","particleSystem"],["spriteManager","spriteManager"],["shaderMaterial","shaderMaterial"]];function Qx(e){const t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r.buffer}function Ev(e){const t=new Uint8Array(Qx(e));return new TextDecoder("utf-8").decode(t)}function eT(e){if(e.files&&typeof e.files=="object"&&e.v!==void 0||typeof e.code=="string")return"playground";for(const[t,r]of Xx)if(t in e)return r;return"unknown"}function tT(e,t,r,o){let n;switch(t){case"gui":{typeof e.encodedGui=="string"?n=JSON.parse(Ev(e.encodedGui)):n=typeof e.gui=="string"?JSON.parse(e.gui):e.gui;break}case"animation":{typeof e.animations=="string"?n=JSON.parse(e.animations):e.animations!==void 0?n=e.animations:typeof e.animation=="string"?n=JSON.parse(e.animation):n=e.animation;break}default:{const a=e[t];n=typeof a=="string"?JSON.parse(a):a;break}}return{snippetId:r,type:t,metadata:o,data:n,load:i=>i?i(n):n}}let iu=null;async function nT(){return await import("monaco-editor/esm/vs/language/typescript/lib/typescriptServices")}async function rT(){return iu||(iu=nT().then(e=>e.typescript)),await iu}async function oT(e,t){const r=await rT();return r.transpileModule(e,{compilerOptions:{target:r.ScriptTarget.ESNext,module:r.ModuleKind.ESNext,jsx:t.endsWith(".tsx")?r.JsxEmit.ReactJSX:void 0,esModuleInterop:!1,allowJs:!0,sourceMap:!1,isolatedModules:!0,strict:!1,allowUmdGlobalAccess:!0},fileName:t}).outputText}async function iT(e,t){const r={},o=[];for(const[n,i]of Object.entries(e))if(/\.tsx?$/i.test(n)){const a=n.replace(/\.tsx?$/i,".js");o.push((async()=>{r[a]=await Promise.resolve(t(i,n))})())}else r[n]=i;return await Promise.all(o),r}const zv=["delayCreateScene","delayLoadScene","createScene","CreateScene","createscene"];function aT(e){if(e.includes("class Playground"))return"TS";if(zv.some(o=>e.includes(o))||!e)return"JS";const t=[/\binterface\s+[A-Za-z_]\w*/m,/\benum\s+[A-Za-z_]\w*/m,/\btype\s+[A-Za-z_]\w*\s*=/m,/\bimplements\s+[A-Za-z_]/m,/\breadonly\b/m,/\bpublic\b|\bprivate\b|\bprotected\b/m,/\babstract\s+class\b/m,/\bas\s+const\b/m,/\bimport\s+type\s+/m],r=/[:]\s*[A-Za-z_$][\w$.<>,\s?\\[\]|&]*\b(?![:=])/m.test(e);return t.some(o=>o.test(e))||r?"TS":"JS"}function sT(e,t){let r=e;if(t==="JS"){const n=r.search(/(?:var|let|const|function)\s+(?:createScene|delayCreateScene|delayLoadScene|createEngine|CreateScene)\b/),i=n>0?r.slice(0,n):"";i&&(r=i.replace(/^[^\S\n]*(?:var|let|const)\s+canvas\s*=\s*document\.getElementById\s*\([^)]*\)\s*;?[^\S\n]*$/gm,"// [snippet-loader] canvas provided by host").replace(/^[^\S\n]*(?:var|let|const)\s+engine\s*=\s*new\s+BABYLON\.\w*Engine\b[^;]*;?[^\S\n]*$/gm,"// [snippet-loader] engine provided by host")+r.slice(n))}const o=t==="TS"?"Playground":zv.find(n=>r.includes(n))??"createScene";return r+=`
100
100
  export default ${o}
101
101
  `,t==="JS"&&/\bfunction\s+createEngine\b|\bvar\s+createEngine\s*=|\bconst\s+createEngine\s*=|\blet\s+createEngine\s*=/.test(r)&&(r+=`
102
102
  export { createEngine }