import * as THREE from 'three'; // octupole export function octupole(length=150) { const OctupoleContiner = new THREE.Object3D(); const OctupoleMaster = new THREE.Object3D(); const dmaterial = new THREE.MeshLambertMaterial({color: 0xf01988}); // support high const geometry_1 = new THREE.BoxGeometry(length, 100, 150); const dmesh_1 = new THREE.Mesh(geometry_1, dmaterial); dmesh_1.position.set(0, 324, 0); OctupoleMaster.add(dmesh_1); // support side const dmesh_2 = new THREE.Mesh(geometry_1, dmaterial); dmesh_2.position.set(0, 299, -124); dmesh_2.rotateX(-Math.PI / 8); OctupoleMaster.add(dmesh_2); const geometry3 = new THREE.BoxGeometry(length-30, 120, 50); const dmesh3 = new THREE.Mesh(geometry3, dmaterial); dmesh3.position.set(0, 140, 0); OctupoleMaster.add(dmesh3); // coil const coilmaterial = new THREE.MeshLambertMaterial({color: 0xc08000}); const textureLoader = new THREE.TextureLoader(); const texture = textureLoader.load('./components/coil_texture.png'); texture.wrapS = texture.wrapT = THREE.RepeatWrapping; texture.repeat.set(5, 5); const d6geometry = new THREE.CylinderGeometry(80 /*radiusTop*/, 80 /*radiusBottom*/, 80 /*height*/, 25 /*radialSegments*/, 4 /*heightSegments*/, false /*openEnded*/,Math.PI * 1.5 /*thetaStart*/, Math.PI * 2 /*thetaLength*/); const material6 = new THREE.MeshBasicMaterial({ map: texture }); const materialside6 = new THREE.MeshBasicMaterial({color: 0xcd7f32}); const materials6 = [material6, materialside6, materialside6]; const d6mesh = new THREE.Mesh(d6geometry, materials6); d6mesh.position.set(0, 230, 0); d6mesh.rotateX(Math.PI * 1.50); d6mesh.rotateY(Math.PI * 1.50); d6mesh.rotateZ(Math.PI * 1.50); OctupoleMaster.add(d6mesh); for (let i=1; i<8; i++) { const Octupole2 = OctupoleMaster.clone(); Octupole2.rotateX(-Math.PI / 4*i); OctupoleContiner.add(Octupole2); } OctupoleContiner.add(OctupoleMaster); OctupoleContiner.rotateY(Math.PI * -0.5); return OctupoleContiner; }