Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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;
}