撮箕2020-3-8
1 export function spheredo($step: Step) { 2 const $solid = $step.$('x-solid') as Solid; 3 4 $solid.addMesh(() => { 5 6 $solid.addPoint([2.3/2.3, -1/2.3, 0], 0x22ab24); 7 $solid.addLabel('P', [2.3/2.3, -1/2.3, 0], 0x22ab24, '0 0 0 -15px'); 8 9 $solid.addPoint([2.3/2.3, 3/2.3, 1/2.3], 0x22ab24); 10 $solid.addLabel('Q', [2.3/2.3, 3/2.3, 1/2.3], 0x22ab24, '0 0 0 -15px'); 11 12 13 $solid.addSegment([2.3/2.3, -1/2.3, 0], [2.3/2.3, 3/2.3, 1/2.3], 0xcd0e66); 14 // $solid.addLabel('r', [0.9, 0, 0], 0xcd0e66); 15 16 17 $solid.addPoint([4.6/2.3, -2/2.3, 0], 0x22ab24); 18 $solid.addLabel('A', [4.6/2.3, -2/2.3, 0], 0x22ab24, '0 0 0 -15px'); 19 20 $solid.addPoint([4.6/2.3, 4/2.3, 0], 0x22ab24); 21 $solid.addLabel('B', [4.6/2.3, 4/2.3, 0], 0x22ab24, '0 0 0 -15px'); 22 23 $solid.addPoint([0, 2/2.3, 0], 0x22ab24); 24 $solid.addLabel('C', [0, 2/2.3, 0], 0x22ab24, '0 0 0 -15px'); 25 26 $solid.addPoint([0, 0, 0], 0x22ab24); 27 $solid.addLabel('D', [0, 0, 0], 0x22ab24, '0 0 0 -15px'); 28 29 $solid.addPoint([0, 2/2.3, 2/2.3], 0x22ab24); 30 $solid.addLabel('E', [0, 2/2.3, 2/2.3], 0x22ab24, '0 0 0 -15px'); 31 32 $solid.addPoint([0, 0, 2/2.3], 0x22ab24); 33 $solid.addLabel('F', [0, 0, 2/2.3], 0x22ab24, '0 0 0 -15px'); 34 35 var geometry = new THREE.Geometry(); 36 37 // 添加6个顶点 38 geometry.vertices.push(new THREE.Vector3(4.6/2.3, -2/2.3, 0)); 39 geometry.vertices.push(new THREE.Vector3(4.6/2.3, 4/2.3, 0)); 40 geometry.vertices.push(new THREE.Vector3(0, 2/2.3, 0)); 41 geometry.vertices.push(new THREE.Vector3(0, 0, 0)); 42 geometry.vertices.push(new THREE.Vector3(0, 2/2.3, 2/2.3)); 43 geometry.vertices.push(new THREE.Vector3(0, 0, 2/2.3)); 44 45 // 添加6个三角形的面 46 geometry.faces.push(new THREE.Face3(0, 3, 1)); 47 geometry.faces.push(new THREE.Face3(1, 3, 2)); 48 geometry.faces.push(new THREE.Face3(3, 5, 2)); 49 geometry.faces.push(new THREE.Face3(2, 5, 4)); 50 geometry.faces.push(new THREE.Face3(0, 5, 3)); 51 geometry.faces.push(new THREE.Face3(1, 2, 4)); 52 53 // $solid.addSolid(geometry, 0x0f82f2); 54 55 $solid.addOutlined(geometry, 0x0f82f2); 56 57 $solid.object.rotateX((Math.PI / 2)*3); 58 $solid.object.rotateZ((Math.PI / 2)*3); 59 60 61 62 }); 63 }