From fab6c1227dd6415e705b377228c60115329c9b88 Mon Sep 17 00:00:00 2001 From: Lucio Zambon <lucio.zambon@elettra.eu> Date: Fri, 6 Dec 2024 15:30:52 +0000 Subject: [PATCH] Add new file --- bending_2400.js | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 bending_2400.js diff --git a/bending_2400.js b/bending_2400.js new file mode 100644 index 0000000..649d683 --- /dev/null +++ b/bending_2400.js @@ -0,0 +1,58 @@ + import * as THREE from 'three'; + + // Bending 2400 + export function bending_2400(param) { + const length = param && typeof param.length == "number"? param.length: 2400 + const bending_2400Container = new THREE.Object3D(); + const bending_2400Object = new THREE.Object3D(); + + // main body + const loader = new THREE.TextureLoader(); + const texture = loader.load('./components/dipole.png'); + const textureTop = texture.clone(); + const textureSide = texture.clone(); + textureTop.center.set(0.5, 0.5); + textureTop.rotation = THREE.MathUtils.degToRad(90); + textureSide.offset.set(0, 0.8); + const dmaterial = new THREE.MeshLambertMaterial({map: texture}); + const face = new THREE.MeshBasicMaterial({map: texture}); + const faceTop = new THREE.MeshBasicMaterial({map: textureTop}); + const faceSide = new THREE.MeshBasicMaterial({map: textureSide}); + const materials = [face,face,faceTop,faceSide,faceSide,faceSide]; + const d1geometry = new THREE.BoxGeometry(500, 700, length); + const d1mesh = new THREE.Mesh(d1geometry, materials); + d1mesh.position.set(100, 100, 0); + bending_2400Object.add(d1mesh); + + // longitudinal coil + const dipoleCoil = new THREE.Object3D(); + const coilmaterial = new THREE.MeshLambertMaterial({color: 0xc08000}); + const d4geometry = new THREE.BoxGeometry(100, 100, length); + const d4mesh = new THREE.Mesh(d4geometry, coilmaterial); + d4mesh.position.set(-200, 0, 0); + dipoleCoil.add(d4mesh); + + // cylinder coil front + const d2geometry = new THREE.CylinderGeometry(150 /*radiusTop*/, 150 /*radiusBottom*/, 100 /*height*/, 20 /*radialSegments*/, 2 /*heightSegments*/, false /*openEnded*/,Math.PI * 1.5 /*thetaStart*/, Math.PI * 1 /*thetaLength*/); + const d2mesh = new THREE.Mesh(d2geometry, coilmaterial); + d2mesh.position.set(-100, 0, length/2); + dipoleCoil.add(d2mesh); + + // cylinder coil back + const d3geometry = new THREE.CylinderGeometry(150 /*radiusTop*/, 150 /*radiusBottom*/, 100 /*height*/, 20 /*radialSegments*/, 2 /*heightSegments*/, false /*openEnded*/,Math.PI * 0.5 /*thetaStart*/, Math.PI * 1 /*thetaLength*/); + const d3mesh = new THREE.Mesh(d3geometry, coilmaterial); + d3mesh.position.set(-100, 0, -length/2); + dipoleCoil.add(d3mesh); + dipoleCoil.position.set(0, 0, 0); + bending_2400Object.add(dipoleCoil); + + // duplicate coil + const dipoleCoil2 = dipoleCoil.clone(); + dipoleCoil2.position.set(0, 200, 0); + bending_2400Object.add(dipoleCoil2); + + bending_2400Object.position.set(0, 0, 0); + bending_2400Container.add(bending_2400Object); + + return bending_2400Container; + } -- GitLab