Files
vibemake/scripts/experience-fixtures.mjs
Jerry 1c837766cd feat: integrate robot assembly and simulation with resilient loading
Add backend-driven assembly and simulation experiences, MAKE branding, mobile rendering budgets and desktop-only CAD/PCB routes. Improve logo loading progress, document image recovery and URDF request handling; include dev packaging and regression coverage.
2026-10-30 18:38:39 +08:00

27 lines
2.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 可重复生成的协议验证积木,不是实际机器人的安装步骤。
import { Document, NodeIO } from '@gltf-transform/core';
import { mkdirSync, writeFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { createHash } from 'node:crypto';
const root=fileURLToPath(new URL('../deliverables/experience-packages/multipart-check/',import.meta.url));
mkdirSync(root,{recursive:true});
const positions = new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1, -1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1]);
const indices=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,4,0,3,4,3,5,1,7,6,1,6,2,3,2,6,3,6,5,4,7,1,4,1,0]);
const files=[];
for(const [name,color] of [['base',[0.1,0.3,0.9,1]],['arm',[0.4,0.8,0.15,1]],['cap',[0.9,0.2,0.1,1]]]){
const doc=new Document(), buffer=doc.createBuffer();
const mat=doc.createMaterial().setBaseColorFactor(color).setMetallicFactor(0.2).setRoughnessFactor(0.4);
const primitive=doc.createPrimitive().setAttribute('POSITION',doc.createAccessor().setType('VEC3').setArray(positions).setBuffer(buffer)).setIndices(doc.createAccessor().setType('SCALAR').setArray(indices).setBuffer(buffer)).setMaterial(mat);
doc.createScene().addChild(doc.createNode().setMesh(doc.createMesh().addPrimitive(primitive)));
const bytes=await new NodeIO().writeBinary(doc);writeFileSync(root+name+'.glb',bytes);
files.push({path:name+'.glb',bytes:bytes.length,sha256:createHash('sha256').update(bytes).digest('hex')});
}
const manifest={schemaVersion:1,kind:'assembly',unit:'meter',title:'多零件测试积木',files,parts:[
{id:'base',file:'base.glb',scale:[0.2,0.04,0.15]},
{id:'left',file:'arm.glb',parentId:'base',position:[-0.6,3,0],scale:[0.2,2,0.3],installOffset:[0,4,0]},
{id:'right',file:'arm.glb',parentId:'base',position:[0.6,3,0],scale:[0.2,2,0.3],installOffset:[0,4,0]},
{id:'cap',file:'cap.glb',position:[0,0.24,0],scale:[0.2,0.04,0.15]}],steps:[
{id:'s1',label:'安装底座',parts:['base']},{id:'s2',label:'安装左侧支撑',parts:['left']},{id:'s3',label:'安装右侧支撑(复用 GLB)',parts:['right']},{id:'s4',label:'安装顶部',parts:['cap']}]};
writeFileSync(root+'manifest.json',JSON.stringify(manifest,null,2));
console.log(root+'manifest.json');