MCPcopy Create free account
hub / github.com/Mesh2Motion/mesh2motion-app / CustomViewHelper

Class CustomViewHelper

src/lib/CustomViewHelper.ts:41–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41export class CustomViewHelper extends Object3D {
42 public is_view_helper: boolean
43 public center: Vector3
44
45 private animating: boolean = false
46 private readonly options: ViewHelperOptions = {}
47 private readonly interactiveObjects: Sprite[] = []
48 private readonly raycaster = new Raycaster()
49 private readonly mouse = new Vector2()
50 private readonly dummy = new Object3D()
51 private readonly orthoCamera = new OrthographicCamera(-2, 2, 2, -2, 0, 4)
52 private readonly geometry: CylinderGeometry
53 private readonly xAxis: Mesh
54 private readonly yAxis: Mesh
55 private readonly zAxis: Mesh
56 private readonly posXAxisHelper: Sprite
57 private readonly posYAxisHelper: Sprite
58 private readonly posZAxisHelper: Sprite
59 private readonly negXAxisHelper: Sprite
60 private readonly negYAxisHelper: Sprite
61 private readonly negZAxisHelper: Sprite
62 private readonly point: Vector3 = new Vector3()
63 private readonly dim: number = 128
64 private readonly turnRate: number = 2 * Math.PI
65 private readonly targetPosition: Vector3 = new Vector3()
66 private readonly targetQuaternion: Quaternion = new Quaternion()
67 private readonly q1: Quaternion = new Quaternion()
68 private readonly q2: Quaternion = new Quaternion()
69 private readonly viewport: Vector4 = new Vector4()
70 private radius: number = 0
71 private readonly camera: Camera
72 private readonly domElement: HTMLElement
73
74 constructor (camera: Camera, domElement: HTMLElement) {
75 super()
76 this.is_view_helper = true
77 this.animating = false
78 this.center = new Vector3()
79 this.camera = camera
80 this.domElement = domElement
81
82 const color1 = new Color('#ff4466')
83 const color2 = new Color('#88ff44')
84 const color3 = new Color('#4488ff')
85 const color4 = new Color('#000000')
86
87 this.orthoCamera.position.set(0, 0, 2)
88 this.geometry = new CylinderGeometry(0.04, 0.04, 0.8, 5).rotateZ(-Math.PI / 2).translate(0.4, 0, 0)
89 this.xAxis = new Mesh(this.geometry, this.getAxisMaterial(color1))
90 this.yAxis = new Mesh(this.geometry, this.getAxisMaterial(color2))
91 this.zAxis = new Mesh(this.geometry, this.getAxisMaterial(color3))
92 this.yAxis.rotation.z = Math.PI / 2
93 this.zAxis.rotation.y = -Math.PI / 2
94 this.add(this.xAxis)
95 this.add(this.zAxis)
96 this.add(this.yAxis)
97 const spriteMaterial1 = this.getSpriteMaterial(color1)
98 const spriteMaterial2 = this.getSpriteMaterial(color2)

Callers

nothing calls this directly

Calls 8

updateLabelsMethod · 0.95
invertMethod · 0.80
setMethod · 0.80
addMethod · 0.80
copyMethod · 0.45
updateMatrixWorldMethod · 0.45
disposeMethod · 0.45

Tested by

no test coverage detected