opal-js_wrap-three 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (503) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Gemfile.lock +4 -4
  4. data/lib/opal/js_wrap/three/version.rb +1 -1
  5. data/lib-opal/js_wrap/three/WebGL.js +102 -0
  6. data/lib-opal/js_wrap/three/animation/AnimationClipCreator.js +116 -0
  7. data/lib-opal/js_wrap/three/animation/CCDIKSolver.js +436 -0
  8. data/lib-opal/js_wrap/three/animation/MMDAnimationHelper.js +941 -0
  9. data/lib-opal/js_wrap/three/animation/MMDPhysics.js +1183 -0
  10. data/lib-opal/js_wrap/three/cameras/CinematicCamera.js +204 -0
  11. data/lib-opal/js_wrap/three/controls/ArcballControls.js +2649 -0
  12. data/lib-opal/js_wrap/three/controls/DragControls.js +234 -0
  13. data/lib-opal/js_wrap/three/controls/FirstPersonControls.js +301 -0
  14. data/lib-opal/js_wrap/three/controls/FlyControls.js +357 -0
  15. data/lib-opal/js_wrap/three/controls/OrbitControls.js +908 -0
  16. data/lib-opal/js_wrap/three/controls/PointerLockControls.js +173 -0
  17. data/lib-opal/js_wrap/three/controls/TrackballControls.js +666 -0
  18. data/lib-opal/js_wrap/three/controls/TransformControls.js +1210 -0
  19. data/lib-opal/js_wrap/three/controls/experimental/CameraControls.js +860 -0
  20. data/lib-opal/js_wrap/three/csm/CSM.js +346 -0
  21. data/lib-opal/js_wrap/three/csm/CSMFrustum.js +123 -0
  22. data/lib-opal/js_wrap/three/csm/CSMHelper.js +197 -0
  23. data/lib-opal/js_wrap/three/csm/CSMShader.js +29 -0
  24. data/lib-opal/js_wrap/three/curves/CurveExtras.js +544 -0
  25. data/lib-opal/js_wrap/three/curves/NURBSCurve.js +122 -0
  26. data/lib-opal/js_wrap/three/curves/NURBSSurface.js +78 -0
  27. data/lib-opal/js_wrap/three/curves/NURBSUtils.js +413 -0
  28. data/lib-opal/js_wrap/three/deprecated/Geometry.js +1373 -0
  29. data/lib-opal/js_wrap/three/effects/AnaglyphEffect.js +113 -0
  30. data/lib-opal/js_wrap/three/effects/AsciiEffect.js +267 -0
  31. data/lib-opal/js_wrap/three/effects/OutlineEffect.js +400 -0
  32. data/lib-opal/js_wrap/three/effects/ParallaxBarrierEffect.js +90 -0
  33. data/lib-opal/js_wrap/three/effects/PeppersGhostEffect.js +160 -0
  34. data/lib-opal/js_wrap/three/effects/StereoEffect.js +63 -0
  35. data/lib-opal/js_wrap/three/environments/DebugEnvironment.js +107 -0
  36. data/lib-opal/js_wrap/three/environments/RoomEnvironment.js +166 -0
  37. data/lib-opal/js_wrap/three/exporters/ColladaExporter.js +442 -0
  38. data/lib-opal/js_wrap/three/exporters/DRACOExporter.js +205 -0
  39. data/lib-opal/js_wrap/three/exporters/GLTFExporter.js +2042 -0
  40. data/lib-opal/js_wrap/three/exporters/MMDExporter.js +189 -0
  41. data/lib-opal/js_wrap/three/exporters/OBJExporter.js +241 -0
  42. data/lib-opal/js_wrap/three/exporters/PLYExporter.js +370 -0
  43. data/lib-opal/js_wrap/three/exporters/STLExporter.js +186 -0
  44. data/lib-opal/js_wrap/three/exporters/USDZExporter.js +402 -0
  45. data/lib-opal/js_wrap/three/geometries/BoxLineGeometry.js +106 -0
  46. data/lib-opal/js_wrap/three/geometries/ConvexGeometry.js +88 -0
  47. data/lib-opal/js_wrap/three/geometries/DecalGeometry.js +302 -0
  48. data/lib-opal/js_wrap/three/geometries/LightningStrike.js +817 -0
  49. data/lib-opal/js_wrap/three/geometries/ParametricGeometries.js +280 -0
  50. data/lib-opal/js_wrap/three/geometries/ParametricGeometry.js +146 -0
  51. data/lib-opal/js_wrap/three/geometries/RoundedBoxGeometry.js +183 -0
  52. data/lib-opal/js_wrap/three/geometries/TeapotGeometry.js +352 -0
  53. data/lib-opal/js_wrap/three/geometries/TextGeometry.js +76 -0
  54. data/lib-opal/js_wrap/three/helpers/LightProbeHelper.js +95 -0
  55. data/lib-opal/js_wrap/three/helpers/PositionalAudioHelper.js +138 -0
  56. data/lib-opal/js_wrap/three/helpers/RectAreaLightHelper.js +115 -0
  57. data/lib-opal/js_wrap/three/helpers/VertexNormalsHelper.js +131 -0
  58. data/lib-opal/js_wrap/three/helpers/VertexTangentsHelper.js +118 -0
  59. data/lib-opal/js_wrap/three/interactive/HTMLMesh.js +307 -0
  60. data/lib-opal/js_wrap/three/interactive/InteractiveGroup.js +138 -0
  61. data/lib-opal/js_wrap/three/interactive/SelectionBox.js +264 -0
  62. data/lib-opal/js_wrap/three/interactive/SelectionHelper.js +88 -0
  63. data/lib-opal/js_wrap/three/libs/OimoPhysics/OimoPhysics.js +46059 -0
  64. data/lib-opal/js_wrap/three/libs/OimoPhysics/index.js +92 -0
  65. data/lib-opal/js_wrap/three/libs/chevrotain.module.min.js +6947 -0
  66. data/lib-opal/js_wrap/three/libs/ecsy.module.js +1999 -0
  67. data/lib-opal/js_wrap/three/libs/fflate.module.js +3002 -0
  68. data/lib-opal/js_wrap/three/libs/flow.module.js +3033 -0
  69. data/lib-opal/js_wrap/three/libs/ktx-parse.module.js +392 -0
  70. data/lib-opal/js_wrap/three/libs/lil-gui.module.min.js +821 -0
  71. data/lib-opal/js_wrap/three/libs/meshopt_decoder.module.js +136 -0
  72. data/lib-opal/js_wrap/three/libs/mmdparser.module.js +11022 -0
  73. data/lib-opal/js_wrap/three/libs/motion-controllers.module.js +589 -0
  74. data/lib-opal/js_wrap/three/libs/opentype.module.min.js +6132 -0
  75. data/lib-opal/js_wrap/three/libs/potpack.module.js +171 -0
  76. data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.js +6781 -0
  77. data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.module.js +6783 -0
  78. data/lib-opal/js_wrap/three/libs/stats.module.js +139 -0
  79. data/lib-opal/js_wrap/three/libs/tween.module.min.js +349 -0
  80. data/lib-opal/js_wrap/three/lights/LightProbeGenerator.js +233 -0
  81. data/lib-opal/js_wrap/three/lights/RectAreaLightUniformsLib.js +75 -0
  82. data/lib-opal/js_wrap/three/lines/Line2.js +66 -0
  83. data/lib-opal/js_wrap/three/lines/LineGeometry.js +122 -0
  84. data/lib-opal/js_wrap/three/lines/LineMaterial.js +227 -0
  85. data/lib-opal/js_wrap/three/lines/LineSegments2.js +312 -0
  86. data/lib-opal/js_wrap/three/lines/LineSegmentsGeometry.js +238 -0
  87. data/lib-opal/js_wrap/three/lines/Wireframe.js +98 -0
  88. data/lib-opal/js_wrap/three/lines/WireframeGeometry2.js +65 -0
  89. data/lib-opal/js_wrap/three/loaders/3DMLoader.js +1230 -0
  90. data/lib-opal/js_wrap/three/loaders/3MFLoader.js +1123 -0
  91. data/lib-opal/js_wrap/three/loaders/AMFLoader.js +445 -0
  92. data/lib-opal/js_wrap/three/loaders/BVHLoader.js +365 -0
  93. data/lib-opal/js_wrap/three/loaders/BasisTextureLoader.js +692 -0
  94. data/lib-opal/js_wrap/three/loaders/ColladaLoader.js +3046 -0
  95. data/lib-opal/js_wrap/three/loaders/DDSLoader.js +264 -0
  96. data/lib-opal/js_wrap/three/loaders/DRACOLoader.js +531 -0
  97. data/lib-opal/js_wrap/three/loaders/EXRLoader.js +1834 -0
  98. data/lib-opal/js_wrap/three/loaders/FBXLoader.js +3125 -0
  99. data/lib-opal/js_wrap/three/loaders/FontLoader.js +201 -0
  100. data/lib-opal/js_wrap/three/loaders/GCodeLoader.js +248 -0
  101. data/lib-opal/js_wrap/three/loaders/GLTFLoader.js +3334 -0
  102. data/lib-opal/js_wrap/three/loaders/HDRCubeTextureLoader.js +144 -0
  103. data/lib-opal/js_wrap/three/loaders/IFCLoader.js +2395 -0
  104. data/lib-opal/js_wrap/three/loaders/KMZLoader.js +142 -0
  105. data/lib-opal/js_wrap/three/loaders/KTX2Loader.js +535 -0
  106. data/lib-opal/js_wrap/three/loaders/KTXLoader.js +202 -0
  107. data/lib-opal/js_wrap/three/loaders/LDrawLoader.js +1737 -0
  108. data/lib-opal/js_wrap/three/loaders/LUT3dlLoader.js +163 -0
  109. data/lib-opal/js_wrap/three/loaders/LUTCubeLoader.js +171 -0
  110. data/lib-opal/js_wrap/three/loaders/LWOLoader.js +831 -0
  111. data/lib-opal/js_wrap/three/loaders/LogLuvLoader.js +713 -0
  112. data/lib-opal/js_wrap/three/loaders/LottieLoader.js +103 -0
  113. data/lib-opal/js_wrap/three/loaders/MD2Loader.js +258 -0
  114. data/lib-opal/js_wrap/three/loaders/MDDLoader.js +116 -0
  115. data/lib-opal/js_wrap/three/loaders/MMDLoader.js +1687 -0
  116. data/lib-opal/js_wrap/three/loaders/MTLLoader.js +465 -0
  117. data/lib-opal/js_wrap/three/loaders/NRRDLoader.js +554 -0
  118. data/lib-opal/js_wrap/three/loaders/NodeMaterialLoader.js +248 -0
  119. data/lib-opal/js_wrap/three/loaders/OBJLoader.js +673 -0
  120. data/lib-opal/js_wrap/three/loaders/PCDLoader.js +322 -0
  121. data/lib-opal/js_wrap/three/loaders/PDBLoader.js +318 -0
  122. data/lib-opal/js_wrap/three/loaders/PLYLoader.js +489 -0
  123. data/lib-opal/js_wrap/three/loaders/PRWMLoader.js +247 -0
  124. data/lib-opal/js_wrap/three/loaders/PVRLoader.js +240 -0
  125. data/lib-opal/js_wrap/three/loaders/RGBELoader.js +462 -0
  126. data/lib-opal/js_wrap/three/loaders/RGBMLoader.js +1169 -0
  127. data/lib-opal/js_wrap/three/loaders/STLLoader.js +345 -0
  128. data/lib-opal/js_wrap/three/loaders/SVGLoader.js +2162 -0
  129. data/lib-opal/js_wrap/three/loaders/TDSLoader.js +982 -0
  130. data/lib-opal/js_wrap/three/loaders/TGALoader.js +444 -0
  131. data/lib-opal/js_wrap/three/loaders/TTFLoader.js +210 -0
  132. data/lib-opal/js_wrap/three/loaders/TiltLoader.js +391 -0
  133. data/lib-opal/js_wrap/three/loaders/VOXLoader.js +272 -0
  134. data/lib-opal/js_wrap/three/loaders/VRMLLoader.js +2685 -0
  135. data/lib-opal/js_wrap/three/loaders/VRMLoader.js +103 -0
  136. data/lib-opal/js_wrap/three/loaders/VTKLoader.js +894 -0
  137. data/lib-opal/js_wrap/three/loaders/XYZLoader.js +136 -0
  138. data/lib-opal/js_wrap/three/loaders/ifc/web-ifc-api.js +60504 -0
  139. data/lib-opal/js_wrap/three/loaders/lwo/IFFParser.js +931 -0
  140. data/lib-opal/js_wrap/three/loaders/lwo/LWO2Parser.js +450 -0
  141. data/lib-opal/js_wrap/three/loaders/lwo/LWO3Parser.js +406 -0
  142. data/lib-opal/js_wrap/three/math/Capsule.js +133 -0
  143. data/lib-opal/js_wrap/three/math/ColorConverter.js +104 -0
  144. data/lib-opal/js_wrap/three/math/ConvexHull.js +924 -0
  145. data/lib-opal/js_wrap/three/math/ImprovedNoise.js +86 -0
  146. data/lib-opal/js_wrap/three/math/Lut.js +170 -0
  147. data/lib-opal/js_wrap/three/math/MeshSurfaceSampler.js +187 -0
  148. data/lib-opal/js_wrap/three/math/OBB.js +345 -0
  149. data/lib-opal/js_wrap/three/math/Octree.js +409 -0
  150. data/lib-opal/js_wrap/three/math/SimplexNoise.js +425 -0
  151. data/lib-opal/js_wrap/three/misc/ConvexObjectBreaker.js +447 -0
  152. data/lib-opal/js_wrap/three/misc/GPUComputationRenderer.js +322 -0
  153. data/lib-opal/js_wrap/three/misc/Gyroscope.js +94 -0
  154. data/lib-opal/js_wrap/three/misc/MD2Character.js +225 -0
  155. data/lib-opal/js_wrap/three/misc/MD2CharacterComplex.js +424 -0
  156. data/lib-opal/js_wrap/three/misc/MorphAnimMesh.js +109 -0
  157. data/lib-opal/js_wrap/three/misc/MorphBlendMesh.js +283 -0
  158. data/lib-opal/js_wrap/three/misc/ProgressiveLightMap.js +324 -0
  159. data/lib-opal/js_wrap/three/misc/RollerCoaster.js +489 -0
  160. data/lib-opal/js_wrap/three/misc/TubePainter.js +158 -0
  161. data/lib-opal/js_wrap/three/misc/Volume.js +427 -0
  162. data/lib-opal/js_wrap/three/misc/VolumeSlice.js +210 -0
  163. data/lib-opal/js_wrap/three/modifiers/CurveModifier.js +291 -0
  164. data/lib-opal/js_wrap/three/modifiers/EdgeSplitModifier.js +308 -0
  165. data/lib-opal/js_wrap/three/modifiers/SimplifyModifier.js +435 -0
  166. data/lib-opal/js_wrap/three/modifiers/TessellateModifier.js +264 -0
  167. data/lib-opal/js_wrap/three/node-editor/NodeEditor.js +402 -0
  168. data/lib-opal/js_wrap/three/node-editor/accessors/NormalEditor.js +80 -0
  169. data/lib-opal/js_wrap/three/node-editor/accessors/PositionEditor.js +80 -0
  170. data/lib-opal/js_wrap/three/node-editor/accessors/UVEditor.js +71 -0
  171. data/lib-opal/js_wrap/three/node-editor/display/BlendEditor.js +78 -0
  172. data/lib-opal/js_wrap/three/node-editor/inputs/ColorEditor.js +111 -0
  173. data/lib-opal/js_wrap/three/node-editor/inputs/FloatEditor.js +69 -0
  174. data/lib-opal/js_wrap/three/node-editor/inputs/SliderEditor.js +97 -0
  175. data/lib-opal/js_wrap/three/node-editor/inputs/Vector2Editor.js +73 -0
  176. data/lib-opal/js_wrap/three/node-editor/inputs/Vector3Editor.js +75 -0
  177. data/lib-opal/js_wrap/three/node-editor/inputs/Vector4Editor.js +77 -0
  178. data/lib-opal/js_wrap/three/node-editor/materials/StandardMaterialEditor.js +121 -0
  179. data/lib-opal/js_wrap/three/node-editor/math/DotEditor.js +76 -0
  180. data/lib-opal/js_wrap/three/node-editor/math/InvertEditor.js +80 -0
  181. data/lib-opal/js_wrap/three/node-editor/math/LimiterEditor.js +85 -0
  182. data/lib-opal/js_wrap/three/node-editor/math/NormalizeEditor.js +69 -0
  183. data/lib-opal/js_wrap/three/node-editor/math/OperatorEditor.js +91 -0
  184. data/lib-opal/js_wrap/three/node-editor/math/PowerEditor.js +73 -0
  185. data/lib-opal/js_wrap/three/node-editor/math/TrigonometryEditor.js +83 -0
  186. data/lib-opal/js_wrap/three/node-editor/procedural/CheckerEditor.js +69 -0
  187. data/lib-opal/js_wrap/three/node-editor/utils/OscillatorEditor.js +87 -0
  188. data/lib-opal/js_wrap/three/node-editor/utils/TimerEditor.js +89 -0
  189. data/lib-opal/js_wrap/three/nodes/Nodes.js +481 -0
  190. data/lib-opal/js_wrap/three/nodes/accessors/CameraNode.js +222 -0
  191. data/lib-opal/js_wrap/three/nodes/accessors/ColorsNode.js +99 -0
  192. data/lib-opal/js_wrap/three/nodes/accessors/LightNode.js +100 -0
  193. data/lib-opal/js_wrap/three/nodes/accessors/NormalNode.js +152 -0
  194. data/lib-opal/js_wrap/three/nodes/accessors/PositionNode.js +163 -0
  195. data/lib-opal/js_wrap/three/nodes/accessors/ReflectNode.js +161 -0
  196. data/lib-opal/js_wrap/three/nodes/accessors/ResolutionNode.js +99 -0
  197. data/lib-opal/js_wrap/three/nodes/accessors/ScreenUVNode.js +101 -0
  198. data/lib-opal/js_wrap/three/nodes/accessors/UVNode.js +105 -0
  199. data/lib-opal/js_wrap/three/nodes/core/AttributeNode.js +106 -0
  200. data/lib-opal/js_wrap/three/nodes/core/ConstNode.js +149 -0
  201. data/lib-opal/js_wrap/three/nodes/core/ExpressionNode.js +57 -0
  202. data/lib-opal/js_wrap/three/nodes/core/FunctionCallNode.js +138 -0
  203. data/lib-opal/js_wrap/three/nodes/core/FunctionNode.js +259 -0
  204. data/lib-opal/js_wrap/three/nodes/core/InputNode.js +124 -0
  205. data/lib-opal/js_wrap/three/nodes/core/Node.js +193 -0
  206. data/lib-opal/js_wrap/three/nodes/core/NodeBuilder.js +782 -0
  207. data/lib-opal/js_wrap/three/nodes/core/NodeFrame.js +69 -0
  208. data/lib-opal/js_wrap/three/nodes/core/NodeLib.js +56 -0
  209. data/lib-opal/js_wrap/three/nodes/core/NodeUniform.js +53 -0
  210. data/lib-opal/js_wrap/three/nodes/core/NodeUtils.js +60 -0
  211. data/lib-opal/js_wrap/three/nodes/core/StructNode.js +131 -0
  212. data/lib-opal/js_wrap/three/nodes/core/TempNode.js +160 -0
  213. data/lib-opal/js_wrap/three/nodes/core/VarNode.js +105 -0
  214. data/lib-opal/js_wrap/three/nodes/effects/BlurNode.js +160 -0
  215. data/lib-opal/js_wrap/three/nodes/effects/ColorAdjustmentNode.js +139 -0
  216. data/lib-opal/js_wrap/three/nodes/effects/LuminanceNode.js +106 -0
  217. data/lib-opal/js_wrap/three/nodes/inputs/BoolNode.js +95 -0
  218. data/lib-opal/js_wrap/three/nodes/inputs/ColorNode.js +99 -0
  219. data/lib-opal/js_wrap/three/nodes/inputs/CubeTextureNode.js +136 -0
  220. data/lib-opal/js_wrap/three/nodes/inputs/FloatNode.js +95 -0
  221. data/lib-opal/js_wrap/three/nodes/inputs/IntNode.js +95 -0
  222. data/lib-opal/js_wrap/three/nodes/inputs/Matrix3Node.js +102 -0
  223. data/lib-opal/js_wrap/three/nodes/inputs/Matrix4Node.js +102 -0
  224. data/lib-opal/js_wrap/three/nodes/inputs/PropertyNode.js +85 -0
  225. data/lib-opal/js_wrap/three/nodes/inputs/RTTNode.js +164 -0
  226. data/lib-opal/js_wrap/three/nodes/inputs/ReflectorNode.js +111 -0
  227. data/lib-opal/js_wrap/three/nodes/inputs/ScreenNode.js +69 -0
  228. data/lib-opal/js_wrap/three/nodes/inputs/TextureNode.js +140 -0
  229. data/lib-opal/js_wrap/three/nodes/inputs/Vector2Node.js +98 -0
  230. data/lib-opal/js_wrap/three/nodes/inputs/Vector3Node.js +99 -0
  231. data/lib-opal/js_wrap/three/nodes/inputs/Vector4Node.js +100 -0
  232. data/lib-opal/js_wrap/three/nodes/materials/BasicNodeMaterial.js +63 -0
  233. data/lib-opal/js_wrap/three/nodes/materials/MeshStandardNodeMaterial.js +63 -0
  234. data/lib-opal/js_wrap/three/nodes/materials/NodeMaterial.js +202 -0
  235. data/lib-opal/js_wrap/three/nodes/materials/PhongNodeMaterial.js +63 -0
  236. data/lib-opal/js_wrap/three/nodes/materials/SpriteNodeMaterial.js +63 -0
  237. data/lib-opal/js_wrap/three/nodes/materials/StandardNodeMaterial.js +63 -0
  238. data/lib-opal/js_wrap/three/nodes/materials/nodes/BasicNode.js +146 -0
  239. data/lib-opal/js_wrap/three/nodes/materials/nodes/MeshStandardNode.js +133 -0
  240. data/lib-opal/js_wrap/three/nodes/materials/nodes/PhongNode.js +273 -0
  241. data/lib-opal/js_wrap/three/nodes/materials/nodes/RawNode.js +101 -0
  242. data/lib-opal/js_wrap/three/nodes/materials/nodes/SpriteNode.js +176 -0
  243. data/lib-opal/js_wrap/three/nodes/materials/nodes/StandardNode.js +397 -0
  244. data/lib-opal/js_wrap/three/nodes/math/CondNode.js +151 -0
  245. data/lib-opal/js_wrap/three/nodes/math/MathNode.js +266 -0
  246. data/lib-opal/js_wrap/three/nodes/math/OperatorNode.js +120 -0
  247. data/lib-opal/js_wrap/three/nodes/misc/BumpMapNode.js +139 -0
  248. data/lib-opal/js_wrap/three/nodes/misc/NormalMapNode.js +122 -0
  249. data/lib-opal/js_wrap/three/nodes/misc/TextureCubeNode.js +107 -0
  250. data/lib-opal/js_wrap/three/nodes/misc/TextureCubeUVNode.js +191 -0
  251. data/lib-opal/js_wrap/three/nodes/postprocessing/NodePass.js +117 -0
  252. data/lib-opal/js_wrap/three/nodes/postprocessing/NodePostProcessing.js +128 -0
  253. data/lib-opal/js_wrap/three/nodes/procedural/CheckerNode.js +104 -0
  254. data/lib-opal/js_wrap/three/nodes/procedural/Fractal3DNode.js +121 -0
  255. data/lib-opal/js_wrap/three/nodes/procedural/Noise2DNode.js +115 -0
  256. data/lib-opal/js_wrap/three/nodes/procedural/Noise3DNode.js +112 -0
  257. data/lib-opal/js_wrap/three/nodes/utils/BypassNode.js +115 -0
  258. data/lib-opal/js_wrap/three/nodes/utils/ColorSpaceNode.js +214 -0
  259. data/lib-opal/js_wrap/three/nodes/utils/JoinNode.js +138 -0
  260. data/lib-opal/js_wrap/three/nodes/utils/MaxMIPLevelNode.js +88 -0
  261. data/lib-opal/js_wrap/three/nodes/utils/RemapNode.js +117 -0
  262. data/lib-opal/js_wrap/three/nodes/utils/SpecularMIPLevelNode.js +121 -0
  263. data/lib-opal/js_wrap/three/nodes/utils/SubSlotNode.js +112 -0
  264. data/lib-opal/js_wrap/three/nodes/utils/SwitchNode.js +129 -0
  265. data/lib-opal/js_wrap/three/nodes/utils/TimerNode.js +126 -0
  266. data/lib-opal/js_wrap/three/nodes/utils/UVTransformNode.js +104 -0
  267. data/lib-opal/js_wrap/three/nodes/utils/VelocityNode.js +181 -0
  268. data/lib-opal/js_wrap/three/objects/Lensflare.js +285 -0
  269. data/lib-opal/js_wrap/three/objects/LightningStorm.js +238 -0
  270. data/lib-opal/js_wrap/three/objects/MarchingCubes.js +667 -0
  271. data/lib-opal/js_wrap/three/objects/Reflector.js +205 -0
  272. data/lib-opal/js_wrap/three/objects/ReflectorForSSRPass.js +288 -0
  273. data/lib-opal/js_wrap/three/objects/ReflectorRTT.js +63 -0
  274. data/lib-opal/js_wrap/three/objects/Refractor.js +243 -0
  275. data/lib-opal/js_wrap/three/objects/ShadowMesh.js +100 -0
  276. data/lib-opal/js_wrap/three/objects/Sky.js +107 -0
  277. data/lib-opal/js_wrap/three/objects/Water.js +246 -0
  278. data/lib-opal/js_wrap/three/objects/Water2.js +238 -0
  279. data/lib-opal/js_wrap/three/offscreen/jank.js +51 -0
  280. data/lib-opal/js_wrap/three/offscreen/offscreen.js +24 -0
  281. data/lib-opal/js_wrap/three/offscreen/scene.js +99 -0
  282. data/lib-opal/js_wrap/three/physics/AmmoPhysics.js +266 -0
  283. data/lib-opal/js_wrap/three/physics/OimoPhysics.js +214 -0
  284. data/lib-opal/js_wrap/three/postprocessing/AdaptiveToneMappingPass.js +307 -0
  285. data/lib-opal/js_wrap/three/postprocessing/AfterimagePass.js +116 -0
  286. data/lib-opal/js_wrap/three/postprocessing/BloomPass.js +132 -0
  287. data/lib-opal/js_wrap/three/postprocessing/BokehPass.js +143 -0
  288. data/lib-opal/js_wrap/three/postprocessing/ClearPass.js +85 -0
  289. data/lib-opal/js_wrap/three/postprocessing/CubeTexturePass.js +104 -0
  290. data/lib-opal/js_wrap/three/postprocessing/DotScreenPass.js +90 -0
  291. data/lib-opal/js_wrap/three/postprocessing/EffectComposer.js +272 -0
  292. data/lib-opal/js_wrap/three/postprocessing/FilmPass.js +91 -0
  293. data/lib-opal/js_wrap/three/postprocessing/GlitchPass.js +140 -0
  294. data/lib-opal/js_wrap/three/postprocessing/HalftonePass.js +108 -0
  295. data/lib-opal/js_wrap/three/postprocessing/LUTPass.js +132 -0
  296. data/lib-opal/js_wrap/three/postprocessing/MaskPass.js +142 -0
  297. data/lib-opal/js_wrap/three/postprocessing/OutlinePass.js +480 -0
  298. data/lib-opal/js_wrap/three/postprocessing/Pass.js +101 -0
  299. data/lib-opal/js_wrap/three/postprocessing/RenderPass.js +109 -0
  300. data/lib-opal/js_wrap/three/postprocessing/SAOPass.js +384 -0
  301. data/lib-opal/js_wrap/three/postprocessing/SMAAPass.js +199 -0
  302. data/lib-opal/js_wrap/three/postprocessing/SSAARenderPass.js +186 -0
  303. data/lib-opal/js_wrap/three/postprocessing/SSAOPass.js +388 -0
  304. data/lib-opal/js_wrap/three/postprocessing/SSRPass.js +537 -0
  305. data/lib-opal/js_wrap/three/postprocessing/SSRrPass.js +481 -0
  306. data/lib-opal/js_wrap/three/postprocessing/SavePass.js +96 -0
  307. data/lib-opal/js_wrap/three/postprocessing/ShaderPass.js +98 -0
  308. data/lib-opal/js_wrap/three/postprocessing/TAARenderPass.js +159 -0
  309. data/lib-opal/js_wrap/three/postprocessing/TexturePass.js +91 -0
  310. data/lib-opal/js_wrap/three/postprocessing/UnrealBloomPass.js +335 -0
  311. data/lib-opal/js_wrap/three/renderers/CSS2DRenderer.js +213 -0
  312. data/lib-opal/js_wrap/three/renderers/CSS3DRenderer.js +277 -0
  313. data/lib-opal/js_wrap/three/renderers/Projector.js +733 -0
  314. data/lib-opal/js_wrap/three/renderers/SVGRenderer.js +470 -0
  315. data/lib-opal/js_wrap/three/renderers/nodes/Nodes.js +531 -0
  316. data/lib-opal/js_wrap/three/renderers/nodes/ShaderNode.js +386 -0
  317. data/lib-opal/js_wrap/three/renderers/nodes/accessors/CameraNode.js +114 -0
  318. data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialNode.js +140 -0
  319. data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialReferenceNode.js +79 -0
  320. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelNode.js +62 -0
  321. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelViewProjectionNode.js +80 -0
  322. data/lib-opal/js_wrap/three/renderers/nodes/accessors/NormalNode.js +113 -0
  323. data/lib-opal/js_wrap/three/renderers/nodes/accessors/Object3DNode.js +136 -0
  324. data/lib-opal/js_wrap/three/renderers/nodes/accessors/PointUVNode.js +70 -0
  325. data/lib-opal/js_wrap/three/renderers/nodes/accessors/PositionNode.js +117 -0
  326. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ReferenceNode.js +124 -0
  327. data/lib-opal/js_wrap/three/renderers/nodes/accessors/SkinningNode.js +129 -0
  328. data/lib-opal/js_wrap/three/renderers/nodes/accessors/UVNode.js +77 -0
  329. data/lib-opal/js_wrap/three/renderers/nodes/core/ArrayInputNode.js +74 -0
  330. data/lib-opal/js_wrap/three/renderers/nodes/core/AttributeNode.js +97 -0
  331. data/lib-opal/js_wrap/three/renderers/nodes/core/BypassNode.js +84 -0
  332. data/lib-opal/js_wrap/three/renderers/nodes/core/CodeNode.js +131 -0
  333. data/lib-opal/js_wrap/three/renderers/nodes/core/ContextNode.js +84 -0
  334. data/lib-opal/js_wrap/three/renderers/nodes/core/ExpressionNode.js +81 -0
  335. data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionCallNode.js +123 -0
  336. data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionNode.js +126 -0
  337. data/lib-opal/js_wrap/three/renderers/nodes/core/InputNode.js +103 -0
  338. data/lib-opal/js_wrap/three/renderers/nodes/core/Node.js +120 -0
  339. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeAttribute.js +37 -0
  340. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeBuilder.js +650 -0
  341. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeCode.js +42 -0
  342. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFrame.js +70 -0
  343. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunction.js +55 -0
  344. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunctionInput.js +44 -0
  345. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeKeywords.js +117 -0
  346. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeParser.js +46 -0
  347. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeUniform.js +55 -0
  348. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVar.js +37 -0
  349. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVary.js +37 -0
  350. data/lib-opal/js_wrap/three/renderers/nodes/core/PropertyNode.js +90 -0
  351. data/lib-opal/js_wrap/three/renderers/nodes/core/TempNode.js +89 -0
  352. data/lib-opal/js_wrap/three/renderers/nodes/core/VarNode.js +101 -0
  353. data/lib-opal/js_wrap/three/renderers/nodes/core/VaryNode.js +101 -0
  354. data/lib-opal/js_wrap/three/renderers/nodes/core/constants.js +42 -0
  355. data/lib-opal/js_wrap/three/renderers/nodes/display/ColorSpaceNode.js +165 -0
  356. data/lib-opal/js_wrap/three/renderers/nodes/display/NormalMapNode.js +120 -0
  357. data/lib-opal/js_wrap/three/renderers/nodes/functions/BSDFs.js +133 -0
  358. data/lib-opal/js_wrap/three/renderers/nodes/inputs/BufferNode.js +78 -0
  359. data/lib-opal/js_wrap/three/renderers/nodes/inputs/ColorNode.js +67 -0
  360. data/lib-opal/js_wrap/three/renderers/nodes/inputs/FloatNode.js +67 -0
  361. data/lib-opal/js_wrap/three/renderers/nodes/inputs/IntNode.js +67 -0
  362. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix3Node.js +67 -0
  363. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix4Node.js +67 -0
  364. data/lib-opal/js_wrap/three/renderers/nodes/inputs/TextureNode.js +120 -0
  365. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector2Node.js +67 -0
  366. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector3Node.js +67 -0
  367. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector4Node.js +67 -0
  368. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightContextNode.js +103 -0
  369. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightNode.js +115 -0
  370. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightsNode.js +117 -0
  371. data/lib-opal/js_wrap/three/renderers/nodes/materials/LineBasicNodeMaterial.js +82 -0
  372. data/lib-opal/js_wrap/three/renderers/nodes/materials/Materials.js +49 -0
  373. data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshBasicNodeMaterial.js +82 -0
  374. data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshStandardNodeMaterial.js +96 -0
  375. data/lib-opal/js_wrap/three/renderers/nodes/materials/PointsNodeMaterial.js +84 -0
  376. data/lib-opal/js_wrap/three/renderers/nodes/math/CondNode.js +98 -0
  377. data/lib-opal/js_wrap/three/renderers/nodes/math/MathNode.js +255 -0
  378. data/lib-opal/js_wrap/three/renderers/nodes/math/OperatorNode.js +163 -0
  379. data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeFunction.js +158 -0
  380. data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeParser.js +68 -0
  381. data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeFunction.js +126 -0
  382. data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeParser.js +68 -0
  383. data/lib-opal/js_wrap/three/renderers/nodes/procedural/CheckerNode.js +84 -0
  384. data/lib-opal/js_wrap/three/renderers/nodes/utils/ArrayElementNode.js +79 -0
  385. data/lib-opal/js_wrap/three/renderers/nodes/utils/ConvertNode.js +82 -0
  386. data/lib-opal/js_wrap/three/renderers/nodes/utils/JoinNode.js +88 -0
  387. data/lib-opal/js_wrap/three/renderers/nodes/utils/OscNode.js +105 -0
  388. data/lib-opal/js_wrap/three/renderers/nodes/utils/SplitNode.js +96 -0
  389. data/lib-opal/js_wrap/three/renderers/nodes/utils/SpriteSheetUVNode.js +98 -0
  390. data/lib-opal/js_wrap/three/renderers/nodes/utils/TimerNode.js +93 -0
  391. data/lib-opal/js_wrap/three/renderers/webgl/nodes/SlotNode.js +72 -0
  392. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodeBuilder.js +463 -0
  393. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodes.js +62 -0
  394. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLPhysicalContextNode.js +95 -0
  395. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPU.js +62 -0
  396. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUAttributes.js +118 -0
  397. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBackground.js +109 -0
  398. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBinding.js +52 -0
  399. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBindings.js +254 -0
  400. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBufferUtils.js +39 -0
  401. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUComputePipelines.js +82 -0
  402. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUGeometries.js +84 -0
  403. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUInfo.js +86 -0
  404. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUObjects.js +64 -0
  405. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProgrammableStage.js +46 -0
  406. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProperties.js +63 -0
  407. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderLists.js +180 -0
  408. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipeline.js +662 -0
  409. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipelines.js +275 -0
  410. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderer.js +883 -0
  411. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampledTexture.js +139 -0
  412. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampler.js +76 -0
  413. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUStorageBuffer.js +69 -0
  414. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureRenderer.js +64 -0
  415. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureUtils.js +125 -0
  416. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextures.js +681 -0
  417. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniform.js +237 -0
  418. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformBuffer.js +90 -0
  419. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformsGroup.js +294 -0
  420. data/lib-opal/js_wrap/three/renderers/webgpu/constants.js +263 -0
  421. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeBuilder.js +619 -0
  422. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampledTexture.js +67 -0
  423. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampler.js +71 -0
  424. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniform.js +229 -0
  425. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.js +68 -0
  426. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodes.js +106 -0
  427. data/lib-opal/js_wrap/three/shaders/ACESFilmicToneMappingShader.js +45 -0
  428. data/lib-opal/js_wrap/three/shaders/AfterimageShader.js +46 -0
  429. data/lib-opal/js_wrap/three/shaders/BasicShader.js +34 -0
  430. data/lib-opal/js_wrap/three/shaders/BleachBypassShader.js +43 -0
  431. data/lib-opal/js_wrap/three/shaders/BlendShader.js +47 -0
  432. data/lib-opal/js_wrap/three/shaders/BokehShader.js +65 -0
  433. data/lib-opal/js_wrap/three/shaders/BokehShader2.js +125 -0
  434. data/lib-opal/js_wrap/three/shaders/BrightnessContrastShader.js +47 -0
  435. data/lib-opal/js_wrap/three/shaders/ColorCorrectionShader.js +47 -0
  436. data/lib-opal/js_wrap/three/shaders/ColorifyShader.js +41 -0
  437. data/lib-opal/js_wrap/three/shaders/ConvolutionShader.js +75 -0
  438. data/lib-opal/js_wrap/three/shaders/CopyShader.js +41 -0
  439. data/lib-opal/js_wrap/three/shaders/DOFMipMapShader.js +49 -0
  440. data/lib-opal/js_wrap/three/shaders/DepthLimitedBlurShader.js +95 -0
  441. data/lib-opal/js_wrap/three/shaders/DigitalGlitch.js +79 -0
  442. data/lib-opal/js_wrap/three/shaders/DotScreenShader.js +52 -0
  443. data/lib-opal/js_wrap/three/shaders/FXAAShader.js +78 -0
  444. data/lib-opal/js_wrap/three/shaders/FilmShader.js +69 -0
  445. data/lib-opal/js_wrap/three/shaders/FocusShader.js +52 -0
  446. data/lib-opal/js_wrap/three/shaders/FreiChenShader.js +44 -0
  447. data/lib-opal/js_wrap/three/shaders/GammaCorrectionShader.js +39 -0
  448. data/lib-opal/js_wrap/three/shaders/GodRaysShader.js +140 -0
  449. data/lib-opal/js_wrap/three/shaders/HalftoneShader.js +77 -0
  450. data/lib-opal/js_wrap/three/shaders/HorizontalBlurShader.js +47 -0
  451. data/lib-opal/js_wrap/three/shaders/HorizontalTiltShiftShader.js +49 -0
  452. data/lib-opal/js_wrap/three/shaders/HueSaturationShader.js +47 -0
  453. data/lib-opal/js_wrap/three/shaders/KaleidoShader.js +50 -0
  454. data/lib-opal/js_wrap/three/shaders/LuminosityHighPassShader.js +52 -0
  455. data/lib-opal/js_wrap/three/shaders/LuminosityShader.js +39 -0
  456. data/lib-opal/js_wrap/three/shaders/MMDToonShader.js +48 -0
  457. data/lib-opal/js_wrap/three/shaders/MirrorShader.js +44 -0
  458. data/lib-opal/js_wrap/three/shaders/NormalMapShader.js +48 -0
  459. data/lib-opal/js_wrap/three/shaders/PixelShader.js +44 -0
  460. data/lib-opal/js_wrap/three/shaders/RGBShiftShader.js +50 -0
  461. data/lib-opal/js_wrap/three/shaders/SAOShader.js +85 -0
  462. data/lib-opal/js_wrap/three/shaders/SMAAShader.js +95 -0
  463. data/lib-opal/js_wrap/three/shaders/SSAOShader.js +113 -0
  464. data/lib-opal/js_wrap/three/shaders/SSRShader.js +126 -0
  465. data/lib-opal/js_wrap/three/shaders/SSRrShader.js +106 -0
  466. data/lib-opal/js_wrap/three/shaders/SepiaShader.js +43 -0
  467. data/lib-opal/js_wrap/three/shaders/SobelOperatorShader.js +44 -0
  468. data/lib-opal/js_wrap/three/shaders/SubsurfaceScatteringShader.js +64 -0
  469. data/lib-opal/js_wrap/three/shaders/TechnicolorShader.js +41 -0
  470. data/lib-opal/js_wrap/three/shaders/ToneMapShader.js +53 -0
  471. data/lib-opal/js_wrap/three/shaders/ToonShader.js +148 -0
  472. data/lib-opal/js_wrap/three/shaders/TriangleBlurShader.js +47 -0
  473. data/lib-opal/js_wrap/three/shaders/UnpackDepthRGBAShader.js +42 -0
  474. data/lib-opal/js_wrap/three/shaders/VerticalBlurShader.js +47 -0
  475. data/lib-opal/js_wrap/three/shaders/VerticalTiltShiftShader.js +49 -0
  476. data/lib-opal/js_wrap/three/shaders/VignetteShader.js +46 -0
  477. data/lib-opal/js_wrap/three/shaders/VolumeShader.js +55 -0
  478. data/lib-opal/js_wrap/three/shaders/WaterRefractionShader.js +46 -0
  479. data/lib-opal/js_wrap/three/textures/FlakesTexture.js +61 -0
  480. data/lib-opal/js_wrap/three/utils/BufferGeometryUtils.js +683 -0
  481. data/lib-opal/js_wrap/three/utils/CameraUtils.js +97 -0
  482. data/lib-opal/js_wrap/three/utils/GPUStatsPanel.js +154 -0
  483. data/lib-opal/js_wrap/three/utils/GeometryCompressionUtils.js +468 -0
  484. data/lib-opal/js_wrap/three/utils/GeometryUtils.js +192 -0
  485. data/lib-opal/js_wrap/three/utils/PackedPhongMaterial.js +77 -0
  486. data/lib-opal/js_wrap/three/utils/RoughnessMipmapper.js +169 -0
  487. data/lib-opal/js_wrap/three/utils/SceneUtils.js +62 -0
  488. data/lib-opal/js_wrap/three/utils/ShadowMapViewer.js +182 -0
  489. data/lib-opal/js_wrap/three/utils/SkeletonUtils.js +400 -0
  490. data/lib-opal/js_wrap/three/utils/UVsDebug.js +132 -0
  491. data/lib-opal/js_wrap/three/utils/WorkerPool.js +130 -0
  492. data/lib-opal/js_wrap/three/webxr/ARButton.js +203 -0
  493. data/lib-opal/js_wrap/three/webxr/OculusHandModel.js +131 -0
  494. data/lib-opal/js_wrap/three/webxr/OculusHandPointerModel.js +328 -0
  495. data/lib-opal/js_wrap/three/webxr/Text2D.js +54 -0
  496. data/lib-opal/js_wrap/three/webxr/VRButton.js +181 -0
  497. data/lib-opal/js_wrap/three/webxr/XRControllerModelFactory.js +266 -0
  498. data/lib-opal/js_wrap/three/webxr/XREstimatedLight.js +221 -0
  499. data/lib-opal/js_wrap/three/webxr/XRHandMeshModel.js +93 -0
  500. data/lib-opal/js_wrap/three/webxr/XRHandModelFactory.js +127 -0
  501. data/lib-opal/js_wrap/three/webxr/XRHandPrimitiveModel.js +85 -0
  502. data/opal-js_wrap-three.gemspec +4 -4
  503. metadata +502 -5
@@ -0,0 +1,2649 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "three"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("three"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.three);
11
+ global.ArcballControls = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _three) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.ArcballControls = void 0;
20
+
21
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
+
23
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
24
+
25
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
26
+
27
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
28
+
29
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
30
+
31
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
32
+
33
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
34
+
35
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
36
+
37
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
38
+
39
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
40
+
41
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
42
+
43
+ //trackball state
44
+ var STATE = {
45
+ IDLE: Symbol(),
46
+ ROTATE: Symbol(),
47
+ PAN: Symbol(),
48
+ SCALE: Symbol(),
49
+ FOV: Symbol(),
50
+ FOCUS: Symbol(),
51
+ ZROTATE: Symbol(),
52
+ TOUCH_MULTI: Symbol(),
53
+ ANIMATION_FOCUS: Symbol(),
54
+ ANIMATION_ROTATE: Symbol()
55
+ };
56
+ var INPUT = {
57
+ NONE: Symbol(),
58
+ ONE_FINGER: Symbol(),
59
+ ONE_FINGER_SWITCHED: Symbol(),
60
+ TWO_FINGER: Symbol(),
61
+ MULT_FINGER: Symbol(),
62
+ CURSOR: Symbol()
63
+ }; //cursor center coordinates
64
+
65
+ var _center = {
66
+ x: 0,
67
+ y: 0
68
+ }; //transformation matrices for gizmos and camera
69
+
70
+ var _transformation = {
71
+ camera: new _three.Matrix4(),
72
+ gizmos: new _three.Matrix4()
73
+ }; //events
74
+
75
+ var _changeEvent = {
76
+ type: 'change'
77
+ };
78
+ var _startEvent = {
79
+ type: 'start'
80
+ };
81
+ var _endEvent = {
82
+ type: 'end'
83
+ };
84
+
85
+ var _raycaster = new _three.Raycaster();
86
+
87
+ var _offset = new _three.Vector3();
88
+ /**
89
+ *
90
+ * @param {Camera} camera Virtual camera used in the scene
91
+ * @param {HTMLElement} domElement Renderer's dom element
92
+ * @param {Scene} scene The scene to be rendered
93
+ */
94
+
95
+
96
+ var ArcballControls = /*#__PURE__*/function (_EventDispatcher) {
97
+ _inherits(ArcballControls, _EventDispatcher);
98
+
99
+ var _super = _createSuper(ArcballControls);
100
+
101
+ function ArcballControls(_camera, domElement) {
102
+ var _this;
103
+
104
+ var scene = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
105
+
106
+ _classCallCheck(this, ArcballControls);
107
+
108
+ _this = _super.call(this);
109
+
110
+ _defineProperty(_assertThisInitialized(_this), "onWindowResize", function () {
111
+ var scale = (_this._gizmos.scale.x + _this._gizmos.scale.y + _this._gizmos.scale.z) / 3;
112
+ _this._tbRadius = _this.calculateTbRadius(_this.camera);
113
+ var newRadius = _this._tbRadius / scale;
114
+ var curve = new _three.EllipseCurve(0, 0, newRadius, newRadius);
115
+ var points = curve.getPoints(_this._curvePts);
116
+ var curveGeometry = new _three.BufferGeometry().setFromPoints(points);
117
+
118
+ for (var gizmo in _this._gizmos.children) {
119
+ _this._gizmos.children[gizmo].geometry = curveGeometry;
120
+ }
121
+
122
+ _this.dispatchEvent(_changeEvent);
123
+ });
124
+
125
+ _defineProperty(_assertThisInitialized(_this), "onContextMenu", function (event) {
126
+ if (!_this.enabled) {
127
+ return;
128
+ }
129
+
130
+ for (var i = 0; i < _this.mouseActions.length; i++) {
131
+ if (_this.mouseActions[i].mouse == 2) {
132
+ //prevent only if button 2 is actually used
133
+ event.preventDefault();
134
+ break;
135
+ }
136
+ }
137
+ });
138
+
139
+ _defineProperty(_assertThisInitialized(_this), "onPointerCancel", function () {
140
+ _this._touchStart.splice(0, _this._touchStart.length);
141
+
142
+ _this._touchCurrent.splice(0, _this._touchCurrent.length);
143
+
144
+ _this._input = INPUT.NONE;
145
+ });
146
+
147
+ _defineProperty(_assertThisInitialized(_this), "onPointerDown", function (event) {
148
+ if (event.button == 0 && event.isPrimary) {
149
+ _this._downValid = true;
150
+
151
+ _this._downEvents.push(event);
152
+
153
+ _this._downStart = performance.now();
154
+ } else {
155
+ _this._downValid = false;
156
+ }
157
+
158
+ if (event.pointerType == 'touch' && _this._input != INPUT.CURSOR) {
159
+ _this._touchStart.push(event);
160
+
161
+ _this._touchCurrent.push(event);
162
+
163
+ switch (_this._input) {
164
+ case INPUT.NONE:
165
+ //singleStart
166
+ _this._input = INPUT.ONE_FINGER;
167
+
168
+ _this.onSinglePanStart(event, 'ROTATE');
169
+
170
+ window.addEventListener('pointermove', _this.onPointerMove);
171
+ window.addEventListener('pointerup', _this.onPointerUp);
172
+ break;
173
+
174
+ case INPUT.ONE_FINGER:
175
+ case INPUT.ONE_FINGER_SWITCHED:
176
+ //doubleStart
177
+ _this._input = INPUT.TWO_FINGER;
178
+
179
+ _this.onRotateStart();
180
+
181
+ _this.onPinchStart();
182
+
183
+ _this.onDoublePanStart();
184
+
185
+ break;
186
+
187
+ case INPUT.TWO_FINGER:
188
+ //multipleStart
189
+ _this._input = INPUT.MULT_FINGER;
190
+
191
+ _this.onTriplePanStart(event);
192
+
193
+ break;
194
+ }
195
+ } else if (event.pointerType != 'touch' && _this._input == INPUT.NONE) {
196
+ var modifier = null;
197
+
198
+ if (event.ctrlKey || event.metaKey) {
199
+ modifier = 'CTRL';
200
+ } else if (event.shiftKey) {
201
+ modifier = 'SHIFT';
202
+ }
203
+
204
+ _this._mouseOp = _this.getOpFromAction(event.button, modifier);
205
+
206
+ if (_this._mouseOp != null) {
207
+ window.addEventListener('pointermove', _this.onPointerMove);
208
+ window.addEventListener('pointerup', _this.onPointerUp); //singleStart
209
+
210
+ _this._input = INPUT.CURSOR;
211
+ _this._button = event.button;
212
+
213
+ _this.onSinglePanStart(event, _this._mouseOp);
214
+ }
215
+ }
216
+ });
217
+
218
+ _defineProperty(_assertThisInitialized(_this), "onPointerMove", function (event) {
219
+ if (event.pointerType == 'touch' && _this._input != INPUT.CURSOR) {
220
+ switch (_this._input) {
221
+ case INPUT.ONE_FINGER:
222
+ //singleMove
223
+ _this.updateTouchEvent(event);
224
+
225
+ _this.onSinglePanMove(event, STATE.ROTATE);
226
+
227
+ break;
228
+
229
+ case INPUT.ONE_FINGER_SWITCHED:
230
+ var movement = _this.calculatePointersDistance(_this._touchCurrent[0], event) * _this._devPxRatio;
231
+
232
+ if (movement >= _this._switchSensibility) {
233
+ //singleMove
234
+ _this._input = INPUT.ONE_FINGER;
235
+
236
+ _this.updateTouchEvent(event);
237
+
238
+ _this.onSinglePanStart(event, 'ROTATE');
239
+
240
+ break;
241
+ }
242
+
243
+ break;
244
+
245
+ case INPUT.TWO_FINGER:
246
+ //rotate/pan/pinchMove
247
+ _this.updateTouchEvent(event);
248
+
249
+ _this.onRotateMove();
250
+
251
+ _this.onPinchMove();
252
+
253
+ _this.onDoublePanMove();
254
+
255
+ break;
256
+
257
+ case INPUT.MULT_FINGER:
258
+ //multMove
259
+ _this.updateTouchEvent(event);
260
+
261
+ _this.onTriplePanMove(event);
262
+
263
+ break;
264
+ }
265
+ } else if (event.pointerType != 'touch' && _this._input == INPUT.CURSOR) {
266
+ var modifier = null;
267
+
268
+ if (event.ctrlKey || event.metaKey) {
269
+ modifier = 'CTRL';
270
+ } else if (event.shiftKey) {
271
+ modifier = 'SHIFT';
272
+ }
273
+
274
+ var mouseOpState = _this.getOpStateFromAction(_this._button, modifier);
275
+
276
+ if (mouseOpState != null) {
277
+ _this.onSinglePanMove(event, mouseOpState);
278
+ }
279
+ } //checkDistance
280
+
281
+
282
+ if (_this._downValid) {
283
+ var _movement = _this.calculatePointersDistance(_this._downEvents[_this._downEvents.length - 1], event) * _this._devPxRatio;
284
+
285
+ if (_movement > _this._movementThreshold) {
286
+ _this._downValid = false;
287
+ }
288
+ }
289
+ });
290
+
291
+ _defineProperty(_assertThisInitialized(_this), "onPointerUp", function (event) {
292
+ if (event.pointerType == 'touch' && _this._input != INPUT.CURSOR) {
293
+ var nTouch = _this._touchCurrent.length;
294
+
295
+ for (var i = 0; i < nTouch; i++) {
296
+ if (_this._touchCurrent[i].pointerId == event.pointerId) {
297
+ _this._touchCurrent.splice(i, 1);
298
+
299
+ _this._touchStart.splice(i, 1);
300
+
301
+ break;
302
+ }
303
+ }
304
+
305
+ switch (_this._input) {
306
+ case INPUT.ONE_FINGER:
307
+ case INPUT.ONE_FINGER_SWITCHED:
308
+ //singleEnd
309
+ window.removeEventListener('pointermove', _this.onPointerMove);
310
+ window.removeEventListener('pointerup', _this.onPointerUp);
311
+ _this._input = INPUT.NONE;
312
+
313
+ _this.onSinglePanEnd();
314
+
315
+ break;
316
+
317
+ case INPUT.TWO_FINGER:
318
+ //doubleEnd
319
+ _this.onDoublePanEnd(event);
320
+
321
+ _this.onPinchEnd(event);
322
+
323
+ _this.onRotateEnd(event); //switching to singleStart
324
+
325
+
326
+ _this._input = INPUT.ONE_FINGER_SWITCHED;
327
+ break;
328
+
329
+ case INPUT.MULT_FINGER:
330
+ if (_this._touchCurrent.length == 0) {
331
+ window.removeEventListener('pointermove', _this.onPointerMove);
332
+ window.removeEventListener('pointerup', _this.onPointerUp); //multCancel
333
+
334
+ _this._input = INPUT.NONE;
335
+
336
+ _this.onTriplePanEnd();
337
+ }
338
+
339
+ break;
340
+ }
341
+ } else if (event.pointerType != 'touch' && _this._input == INPUT.CURSOR) {
342
+ window.removeEventListener('pointermove', _this.onPointerMove);
343
+ window.removeEventListener('pointerup', _this.onPointerUp);
344
+ _this._input = INPUT.NONE;
345
+
346
+ _this.onSinglePanEnd();
347
+
348
+ _this._button = -1;
349
+ }
350
+
351
+ if (event.isPrimary) {
352
+ if (_this._downValid) {
353
+ var downTime = event.timeStamp - _this._downEvents[_this._downEvents.length - 1].timeStamp;
354
+
355
+ if (downTime <= _this._maxDownTime) {
356
+ if (_this._nclicks == 0) {
357
+ //first valid click detected
358
+ _this._nclicks = 1;
359
+ _this._clickStart = performance.now();
360
+ } else {
361
+ var clickInterval = event.timeStamp - _this._clickStart;
362
+
363
+ var movement = _this.calculatePointersDistance(_this._downEvents[1], _this._downEvents[0]) * _this._devPxRatio;
364
+
365
+ if (clickInterval <= _this._maxInterval && movement <= _this._posThreshold) {
366
+ //second valid click detected
367
+ //fire double tap and reset values
368
+ _this._nclicks = 0;
369
+
370
+ _this._downEvents.splice(0, _this._downEvents.length);
371
+
372
+ _this.onDoubleTap(event);
373
+ } else {
374
+ //new 'first click'
375
+ _this._nclicks = 1;
376
+
377
+ _this._downEvents.shift();
378
+
379
+ _this._clickStart = performance.now();
380
+ }
381
+ }
382
+ } else {
383
+ _this._downValid = false;
384
+ _this._nclicks = 0;
385
+
386
+ _this._downEvents.splice(0, _this._downEvents.length);
387
+ }
388
+ } else {
389
+ _this._nclicks = 0;
390
+
391
+ _this._downEvents.splice(0, _this._downEvents.length);
392
+ }
393
+ }
394
+ });
395
+
396
+ _defineProperty(_assertThisInitialized(_this), "onWheel", function (event) {
397
+ if (_this.enabled && _this.enableZoom) {
398
+ var modifier = null;
399
+
400
+ if (event.ctrlKey || event.metaKey) {
401
+ modifier = 'CTRL';
402
+ } else if (event.shiftKey) {
403
+ modifier = 'SHIFT';
404
+ }
405
+
406
+ var mouseOp = _this.getOpFromAction('WHEEL', modifier);
407
+
408
+ if (mouseOp != null) {
409
+ event.preventDefault();
410
+
411
+ _this.dispatchEvent(_startEvent);
412
+
413
+ var notchDeltaY = 125; //distance of one notch of mouse wheel
414
+
415
+ var sgn = event.deltaY / notchDeltaY;
416
+ var size = 1;
417
+
418
+ if (sgn > 0) {
419
+ size = 1 / _this.scaleFactor;
420
+ } else if (sgn < 0) {
421
+ size = _this.scaleFactor;
422
+ }
423
+
424
+ switch (mouseOp) {
425
+ case 'ZOOM':
426
+ _this.updateTbState(STATE.SCALE, true);
427
+
428
+ if (sgn > 0) {
429
+ size = 1 / Math.pow(_this.scaleFactor, sgn);
430
+ } else if (sgn < 0) {
431
+ size = Math.pow(_this.scaleFactor, -sgn);
432
+ }
433
+
434
+ if (_this.cursorZoom && _this.enablePan) {
435
+ var scalePoint;
436
+
437
+ if (_this.camera.isOrthographicCamera) {
438
+ scalePoint = _this.unprojectOnTbPlane(_this.camera, event.clientX, event.clientY, _this.domElement).applyQuaternion(_this.camera.quaternion).multiplyScalar(1 / _this.camera.zoom).add(_this._gizmos.position);
439
+ } else if (_this.camera.isPerspectiveCamera) {
440
+ scalePoint = _this.unprojectOnTbPlane(_this.camera, event.clientX, event.clientY, _this.domElement).applyQuaternion(_this.camera.quaternion).add(_this._gizmos.position);
441
+ }
442
+
443
+ _this.applyTransformMatrix(_this.scale(size, scalePoint));
444
+ } else {
445
+ _this.applyTransformMatrix(_this.scale(size, _this._gizmos.position));
446
+ }
447
+
448
+ if (_this._grid != null) {
449
+ _this.disposeGrid();
450
+
451
+ _this.drawGrid();
452
+ }
453
+
454
+ _this.updateTbState(STATE.IDLE, false);
455
+
456
+ _this.dispatchEvent(_changeEvent);
457
+
458
+ _this.dispatchEvent(_endEvent);
459
+
460
+ break;
461
+
462
+ case 'FOV':
463
+ if (_this.camera.isPerspectiveCamera) {
464
+ _this.updateTbState(STATE.FOV, true); //Vertigo effect
465
+ // fov / 2
466
+ // |\
467
+ // | \
468
+ // | \
469
+ // x | \
470
+ // | \
471
+ // | \
472
+ // | _ _ _\
473
+ // y
474
+ //check for iOs shift shortcut
475
+
476
+
477
+ if (event.deltaX != 0) {
478
+ sgn = event.deltaX / notchDeltaY;
479
+ size = 1;
480
+
481
+ if (sgn > 0) {
482
+ size = 1 / Math.pow(_this.scaleFactor, sgn);
483
+ } else if (sgn < 0) {
484
+ size = Math.pow(_this.scaleFactor, -sgn);
485
+ }
486
+ }
487
+
488
+ _this._v3_1.setFromMatrixPosition(_this._cameraMatrixState);
489
+
490
+ var x = _this._v3_1.distanceTo(_this._gizmos.position);
491
+
492
+ var xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
493
+ //check min and max distance
494
+
495
+ xNew = _three.MathUtils.clamp(xNew, _this.minDistance, _this.maxDistance);
496
+ var y = x * Math.tan(_three.MathUtils.DEG2RAD * _this.camera.fov * 0.5); //calculate new fov
497
+
498
+ var newFov = _three.MathUtils.RAD2DEG * (Math.atan(y / xNew) * 2); //check min and max fov
499
+
500
+ if (newFov > _this.maxFov) {
501
+ newFov = _this.maxFov;
502
+ } else if (newFov < _this.minFov) {
503
+ newFov = _this.minFov;
504
+ }
505
+
506
+ var newDistance = y / Math.tan(_three.MathUtils.DEG2RAD * (newFov / 2));
507
+ size = x / newDistance;
508
+
509
+ _this.setFov(newFov);
510
+
511
+ _this.applyTransformMatrix(_this.scale(size, _this._gizmos.position, false));
512
+ }
513
+
514
+ if (_this._grid != null) {
515
+ _this.disposeGrid();
516
+
517
+ _this.drawGrid();
518
+ }
519
+
520
+ _this.updateTbState(STATE.IDLE, false);
521
+
522
+ _this.dispatchEvent(_changeEvent);
523
+
524
+ _this.dispatchEvent(_endEvent);
525
+
526
+ break;
527
+ }
528
+ }
529
+ }
530
+ });
531
+
532
+ _defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {
533
+ if (event.key == 'c') {
534
+ if (event.ctrlKey || event.metaKey) {
535
+ _this.copyState();
536
+ }
537
+ } else if (event.key == 'v') {
538
+ if (event.ctrlKey || event.metaKey) {
539
+ _this.pasteState();
540
+ }
541
+ }
542
+ });
543
+
544
+ _defineProperty(_assertThisInitialized(_this), "onSinglePanStart", function (event, operation) {
545
+ if (_this.enabled) {
546
+ _this.dispatchEvent(_startEvent);
547
+
548
+ _this.setCenter(event.clientX, event.clientY);
549
+
550
+ switch (operation) {
551
+ case 'PAN':
552
+ if (!_this.enablePan) {
553
+ return;
554
+ }
555
+
556
+ if (_this._animationId != -1) {
557
+ cancelAnimationFrame(_this._animationId);
558
+ _this._animationId = -1;
559
+ _this._timeStart = -1;
560
+
561
+ _this.activateGizmos(false);
562
+
563
+ _this.dispatchEvent(_changeEvent);
564
+ }
565
+
566
+ _this.updateTbState(STATE.PAN, true);
567
+
568
+ _this._startCursorPosition.copy(_this.unprojectOnTbPlane(_this.camera, _center.x, _center.y, _this.domElement));
569
+
570
+ if (_this.enableGrid) {
571
+ _this.drawGrid();
572
+
573
+ _this.dispatchEvent(_changeEvent);
574
+ }
575
+
576
+ break;
577
+
578
+ case 'ROTATE':
579
+ if (!_this.enableRotate) {
580
+ return;
581
+ }
582
+
583
+ if (_this._animationId != -1) {
584
+ cancelAnimationFrame(_this._animationId);
585
+ _this._animationId = -1;
586
+ _this._timeStart = -1;
587
+ }
588
+
589
+ _this.updateTbState(STATE.ROTATE, true);
590
+
591
+ _this._startCursorPosition.copy(_this.unprojectOnTbSurface(_this.camera, _center.x, _center.y, _this.domElement, _this._tbRadius));
592
+
593
+ _this.activateGizmos(true);
594
+
595
+ if (_this.enableAnimations) {
596
+ _this._timePrev = _this._timeCurrent = performance.now();
597
+ _this._angleCurrent = _this._anglePrev = 0;
598
+
599
+ _this._cursorPosPrev.copy(_this._startCursorPosition);
600
+
601
+ _this._cursorPosCurr.copy(_this._cursorPosPrev);
602
+
603
+ _this._wCurr = 0;
604
+ _this._wPrev = _this._wCurr;
605
+ }
606
+
607
+ _this.dispatchEvent(_changeEvent);
608
+
609
+ break;
610
+
611
+ case 'FOV':
612
+ if (!_this.camera.isPerspectiveCamera || !_this.enableZoom) {
613
+ return;
614
+ }
615
+
616
+ if (_this._animationId != -1) {
617
+ cancelAnimationFrame(_this._animationId);
618
+ _this._animationId = -1;
619
+ _this._timeStart = -1;
620
+
621
+ _this.activateGizmos(false);
622
+
623
+ _this.dispatchEvent(_changeEvent);
624
+ }
625
+
626
+ _this.updateTbState(STATE.FOV, true);
627
+
628
+ _this._startCursorPosition.setY(_this.getCursorNDC(_center.x, _center.y, _this.domElement).y * 0.5);
629
+
630
+ _this._currentCursorPosition.copy(_this._startCursorPosition);
631
+
632
+ break;
633
+
634
+ case 'ZOOM':
635
+ if (!_this.enableZoom) {
636
+ return;
637
+ }
638
+
639
+ if (_this._animationId != -1) {
640
+ cancelAnimationFrame(_this._animationId);
641
+ _this._animationId = -1;
642
+ _this._timeStart = -1;
643
+
644
+ _this.activateGizmos(false);
645
+
646
+ _this.dispatchEvent(_changeEvent);
647
+ }
648
+
649
+ _this.updateTbState(STATE.SCALE, true);
650
+
651
+ _this._startCursorPosition.setY(_this.getCursorNDC(_center.x, _center.y, _this.domElement).y * 0.5);
652
+
653
+ _this._currentCursorPosition.copy(_this._startCursorPosition);
654
+
655
+ break;
656
+ }
657
+ }
658
+ });
659
+
660
+ _defineProperty(_assertThisInitialized(_this), "onSinglePanMove", function (event, opState) {
661
+ if (_this.enabled) {
662
+ var restart = opState != _this._state;
663
+
664
+ _this.setCenter(event.clientX, event.clientY);
665
+
666
+ switch (opState) {
667
+ case STATE.PAN:
668
+ if (_this.enablePan) {
669
+ if (restart) {
670
+ //switch to pan operation
671
+ _this.dispatchEvent(_endEvent);
672
+
673
+ _this.dispatchEvent(_startEvent);
674
+
675
+ _this.updateTbState(opState, true);
676
+
677
+ _this._startCursorPosition.copy(_this.unprojectOnTbPlane(_this.camera, _center.x, _center.y, _this.domElement));
678
+
679
+ if (_this.enableGrid) {
680
+ _this.drawGrid();
681
+ }
682
+
683
+ _this.activateGizmos(false);
684
+ } else {
685
+ //continue with pan operation
686
+ _this._currentCursorPosition.copy(_this.unprojectOnTbPlane(_this.camera, _center.x, _center.y, _this.domElement));
687
+
688
+ _this.applyTransformMatrix(_this.pan(_this._startCursorPosition, _this._currentCursorPosition));
689
+ }
690
+ }
691
+
692
+ break;
693
+
694
+ case STATE.ROTATE:
695
+ if (_this.enableRotate) {
696
+ if (restart) {
697
+ //switch to rotate operation
698
+ _this.dispatchEvent(_endEvent);
699
+
700
+ _this.dispatchEvent(_startEvent);
701
+
702
+ _this.updateTbState(opState, true);
703
+
704
+ _this._startCursorPosition.copy(_this.unprojectOnTbSurface(_this.camera, _center.x, _center.y, _this.domElement, _this._tbRadius));
705
+
706
+ if (_this.enableGrid) {
707
+ _this.disposeGrid();
708
+ }
709
+
710
+ _this.activateGizmos(true);
711
+ } else {
712
+ //continue with rotate operation
713
+ _this._currentCursorPosition.copy(_this.unprojectOnTbSurface(_this.camera, _center.x, _center.y, _this.domElement, _this._tbRadius));
714
+
715
+ var distance = _this._startCursorPosition.distanceTo(_this._currentCursorPosition);
716
+
717
+ var angle = _this._startCursorPosition.angleTo(_this._currentCursorPosition);
718
+
719
+ var amount = Math.max(distance / _this._tbRadius, angle); //effective rotation angle
720
+
721
+ _this.applyTransformMatrix(_this.rotate(_this.calculateRotationAxis(_this._startCursorPosition, _this._currentCursorPosition), amount));
722
+
723
+ if (_this.enableAnimations) {
724
+ _this._timePrev = _this._timeCurrent;
725
+ _this._timeCurrent = performance.now();
726
+ _this._anglePrev = _this._angleCurrent;
727
+ _this._angleCurrent = amount;
728
+
729
+ _this._cursorPosPrev.copy(_this._cursorPosCurr);
730
+
731
+ _this._cursorPosCurr.copy(_this._currentCursorPosition);
732
+
733
+ _this._wPrev = _this._wCurr;
734
+ _this._wCurr = _this.calculateAngularSpeed(_this._anglePrev, _this._angleCurrent, _this._timePrev, _this._timeCurrent);
735
+ }
736
+ }
737
+ }
738
+
739
+ break;
740
+
741
+ case STATE.SCALE:
742
+ if (_this.enableZoom) {
743
+ if (restart) {
744
+ //switch to zoom operation
745
+ _this.dispatchEvent(_endEvent);
746
+
747
+ _this.dispatchEvent(_startEvent);
748
+
749
+ _this.updateTbState(opState, true);
750
+
751
+ _this._startCursorPosition.setY(_this.getCursorNDC(_center.x, _center.y, _this.domElement).y * 0.5);
752
+
753
+ _this._currentCursorPosition.copy(_this._startCursorPosition);
754
+
755
+ if (_this.enableGrid) {
756
+ _this.disposeGrid();
757
+ }
758
+
759
+ _this.activateGizmos(false);
760
+ } else {
761
+ //continue with zoom operation
762
+ var screenNotches = 8; //how many wheel notches corresponds to a full screen pan
763
+
764
+ _this._currentCursorPosition.setY(_this.getCursorNDC(_center.x, _center.y, _this.domElement).y * 0.5);
765
+
766
+ var movement = _this._currentCursorPosition.y - _this._startCursorPosition.y;
767
+ var size = 1;
768
+
769
+ if (movement < 0) {
770
+ size = 1 / Math.pow(_this.scaleFactor, -movement * screenNotches);
771
+ } else if (movement > 0) {
772
+ size = Math.pow(_this.scaleFactor, movement * screenNotches);
773
+ }
774
+
775
+ _this.applyTransformMatrix(_this.scale(size, _this._gizmos.position));
776
+ }
777
+ }
778
+
779
+ break;
780
+
781
+ case STATE.FOV:
782
+ if (_this.enableZoom && _this.camera.isPerspectiveCamera) {
783
+ if (restart) {
784
+ //switch to fov operation
785
+ _this.dispatchEvent(_endEvent);
786
+
787
+ _this.dispatchEvent(_startEvent);
788
+
789
+ _this.updateTbState(opState, true);
790
+
791
+ _this._startCursorPosition.setY(_this.getCursorNDC(_center.x, _center.y, _this.domElement).y * 0.5);
792
+
793
+ _this._currentCursorPosition.copy(_this._startCursorPosition);
794
+
795
+ if (_this.enableGrid) {
796
+ _this.disposeGrid();
797
+ }
798
+
799
+ _this.activateGizmos(false);
800
+ } else {
801
+ //continue with fov operation
802
+ var _screenNotches = 8; //how many wheel notches corresponds to a full screen pan
803
+
804
+ _this._currentCursorPosition.setY(_this.getCursorNDC(_center.x, _center.y, _this.domElement).y * 0.5);
805
+
806
+ var _movement2 = _this._currentCursorPosition.y - _this._startCursorPosition.y;
807
+
808
+ var _size = 1;
809
+
810
+ if (_movement2 < 0) {
811
+ _size = 1 / Math.pow(_this.scaleFactor, -_movement2 * _screenNotches);
812
+ } else if (_movement2 > 0) {
813
+ _size = Math.pow(_this.scaleFactor, _movement2 * _screenNotches);
814
+ }
815
+
816
+ _this._v3_1.setFromMatrixPosition(_this._cameraMatrixState);
817
+
818
+ var x = _this._v3_1.distanceTo(_this._gizmos.position);
819
+
820
+ var xNew = x / _size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
821
+ //check min and max distance
822
+
823
+ xNew = _three.MathUtils.clamp(xNew, _this.minDistance, _this.maxDistance);
824
+ var y = x * Math.tan(_three.MathUtils.DEG2RAD * _this._fovState * 0.5); //calculate new fov
825
+
826
+ var newFov = _three.MathUtils.RAD2DEG * (Math.atan(y / xNew) * 2); //check min and max fov
827
+
828
+ newFov = _three.MathUtils.clamp(newFov, _this.minFov, _this.maxFov);
829
+ var newDistance = y / Math.tan(_three.MathUtils.DEG2RAD * (newFov / 2));
830
+ _size = x / newDistance;
831
+
832
+ _this._v3_2.setFromMatrixPosition(_this._gizmoMatrixState);
833
+
834
+ _this.setFov(newFov);
835
+
836
+ _this.applyTransformMatrix(_this.scale(_size, _this._v3_2, false)); //adjusting distance
837
+
838
+
839
+ _offset.copy(_this._gizmos.position).sub(_this.camera.position).normalize().multiplyScalar(newDistance / x);
840
+
841
+ _this._m4_1.makeTranslation(_offset.x, _offset.y, _offset.z);
842
+ }
843
+ }
844
+
845
+ break;
846
+ }
847
+
848
+ _this.dispatchEvent(_changeEvent);
849
+ }
850
+ });
851
+
852
+ _defineProperty(_assertThisInitialized(_this), "onSinglePanEnd", function () {
853
+ if (_this._state == STATE.ROTATE) {
854
+ if (!_this.enableRotate) {
855
+ return;
856
+ }
857
+
858
+ if (_this.enableAnimations) {
859
+ //perform rotation animation
860
+ var deltaTime = performance.now() - _this._timeCurrent;
861
+
862
+ if (deltaTime < 120) {
863
+ var w = Math.abs((_this._wPrev + _this._wCurr) / 2);
864
+
865
+ var self = _assertThisInitialized(_this);
866
+
867
+ _this._animationId = window.requestAnimationFrame(function (t) {
868
+ self.updateTbState(STATE.ANIMATION_ROTATE, true);
869
+ var rotationAxis = self.calculateRotationAxis(self._cursorPosPrev, self._cursorPosCurr);
870
+ self.onRotationAnim(t, rotationAxis, Math.min(w, self.wMax));
871
+ });
872
+ } else {
873
+ //cursor has been standing still for over 120 ms since last movement
874
+ _this.updateTbState(STATE.IDLE, false);
875
+
876
+ _this.activateGizmos(false);
877
+
878
+ _this.dispatchEvent(_changeEvent);
879
+ }
880
+ } else {
881
+ _this.updateTbState(STATE.IDLE, false);
882
+
883
+ _this.activateGizmos(false);
884
+
885
+ _this.dispatchEvent(_changeEvent);
886
+ }
887
+ } else if (_this._state == STATE.PAN || _this._state == STATE.IDLE) {
888
+ _this.updateTbState(STATE.IDLE, false);
889
+
890
+ if (_this.enableGrid) {
891
+ _this.disposeGrid();
892
+ }
893
+
894
+ _this.activateGizmos(false);
895
+
896
+ _this.dispatchEvent(_changeEvent);
897
+ }
898
+
899
+ _this.dispatchEvent(_endEvent);
900
+ });
901
+
902
+ _defineProperty(_assertThisInitialized(_this), "onDoubleTap", function (event) {
903
+ if (_this.enabled && _this.enablePan && _this.scene != null) {
904
+ _this.dispatchEvent(_startEvent);
905
+
906
+ _this.setCenter(event.clientX, event.clientY);
907
+
908
+ var hitP = _this.unprojectOnObj(_this.getCursorNDC(_center.x, _center.y, _this.domElement), _this.camera);
909
+
910
+ if (hitP != null && _this.enableAnimations) {
911
+ var self = _assertThisInitialized(_this);
912
+
913
+ if (_this._animationId != -1) {
914
+ window.cancelAnimationFrame(_this._animationId);
915
+ }
916
+
917
+ _this._timeStart = -1;
918
+ _this._animationId = window.requestAnimationFrame(function (t) {
919
+ self.updateTbState(STATE.ANIMATION_FOCUS, true);
920
+ self.onFocusAnim(t, hitP, self._cameraMatrixState, self._gizmoMatrixState);
921
+ });
922
+ } else if (hitP != null && !_this.enableAnimations) {
923
+ _this.updateTbState(STATE.FOCUS, true);
924
+
925
+ _this.focus(hitP, _this.scaleFactor);
926
+
927
+ _this.updateTbState(STATE.IDLE, false);
928
+
929
+ _this.dispatchEvent(_changeEvent);
930
+ }
931
+ }
932
+
933
+ _this.dispatchEvent(_endEvent);
934
+ });
935
+
936
+ _defineProperty(_assertThisInitialized(_this), "onDoublePanStart", function () {
937
+ if (_this.enabled && _this.enablePan) {
938
+ _this.dispatchEvent(_startEvent);
939
+
940
+ _this.updateTbState(STATE.PAN, true);
941
+
942
+ _this.setCenter((_this._touchCurrent[0].clientX + _this._touchCurrent[1].clientX) / 2, (_this._touchCurrent[0].clientY + _this._touchCurrent[1].clientY) / 2);
943
+
944
+ _this._startCursorPosition.copy(_this.unprojectOnTbPlane(_this.camera, _center.x, _center.y, _this.domElement, true));
945
+
946
+ _this._currentCursorPosition.copy(_this._startCursorPosition);
947
+
948
+ _this.activateGizmos(false);
949
+ }
950
+ });
951
+
952
+ _defineProperty(_assertThisInitialized(_this), "onDoublePanMove", function () {
953
+ if (_this.enabled && _this.enablePan) {
954
+ _this.setCenter((_this._touchCurrent[0].clientX + _this._touchCurrent[1].clientX) / 2, (_this._touchCurrent[0].clientY + _this._touchCurrent[1].clientY) / 2);
955
+
956
+ if (_this._state != STATE.PAN) {
957
+ _this.updateTbState(STATE.PAN, true);
958
+
959
+ _this._startCursorPosition.copy(_this._currentCursorPosition);
960
+ }
961
+
962
+ _this._currentCursorPosition.copy(_this.unprojectOnTbPlane(_this.camera, _center.x, _center.y, _this.domElement, true));
963
+
964
+ _this.applyTransformMatrix(_this.pan(_this._startCursorPosition, _this._currentCursorPosition, true));
965
+
966
+ _this.dispatchEvent(_changeEvent);
967
+ }
968
+ });
969
+
970
+ _defineProperty(_assertThisInitialized(_this), "onDoublePanEnd", function () {
971
+ _this.updateTbState(STATE.IDLE, false);
972
+
973
+ _this.dispatchEvent(_endEvent);
974
+ });
975
+
976
+ _defineProperty(_assertThisInitialized(_this), "onRotateStart", function () {
977
+ if (_this.enabled && _this.enableRotate) {
978
+ _this.dispatchEvent(_startEvent);
979
+
980
+ _this.updateTbState(STATE.ZROTATE, true); //this._startFingerRotation = event.rotation;
981
+
982
+
983
+ _this._startFingerRotation = _this.getAngle(_this._touchCurrent[1], _this._touchCurrent[0]) + _this.getAngle(_this._touchStart[1], _this._touchStart[0]);
984
+ _this._currentFingerRotation = _this._startFingerRotation;
985
+
986
+ _this.camera.getWorldDirection(_this._rotationAxis); //rotation axis
987
+
988
+
989
+ if (!_this.enablePan && !_this.enableZoom) {
990
+ _this.activateGizmos(true);
991
+ }
992
+ }
993
+ });
994
+
995
+ _defineProperty(_assertThisInitialized(_this), "onRotateMove", function () {
996
+ if (_this.enabled && _this.enableRotate) {
997
+ _this.setCenter((_this._touchCurrent[0].clientX + _this._touchCurrent[1].clientX) / 2, (_this._touchCurrent[0].clientY + _this._touchCurrent[1].clientY) / 2);
998
+
999
+ var rotationPoint;
1000
+
1001
+ if (_this._state != STATE.ZROTATE) {
1002
+ _this.updateTbState(STATE.ZROTATE, true);
1003
+
1004
+ _this._startFingerRotation = _this._currentFingerRotation;
1005
+ } //this._currentFingerRotation = event.rotation;
1006
+
1007
+
1008
+ _this._currentFingerRotation = _this.getAngle(_this._touchCurrent[1], _this._touchCurrent[0]) + _this.getAngle(_this._touchStart[1], _this._touchStart[0]);
1009
+
1010
+ if (!_this.enablePan) {
1011
+ rotationPoint = new _three.Vector3().setFromMatrixPosition(_this._gizmoMatrixState);
1012
+ } else {
1013
+ _this._v3_2.setFromMatrixPosition(_this._gizmoMatrixState);
1014
+
1015
+ rotationPoint = _this.unprojectOnTbPlane(_this.camera, _center.x, _center.y, _this.domElement).applyQuaternion(_this.camera.quaternion).multiplyScalar(1 / _this.camera.zoom).add(_this._v3_2);
1016
+ }
1017
+
1018
+ var amount = _three.MathUtils.DEG2RAD * (_this._startFingerRotation - _this._currentFingerRotation);
1019
+
1020
+ _this.applyTransformMatrix(_this.zRotate(rotationPoint, amount));
1021
+
1022
+ _this.dispatchEvent(_changeEvent);
1023
+ }
1024
+ });
1025
+
1026
+ _defineProperty(_assertThisInitialized(_this), "onRotateEnd", function () {
1027
+ _this.updateTbState(STATE.IDLE, false);
1028
+
1029
+ _this.activateGizmos(false);
1030
+
1031
+ _this.dispatchEvent(_endEvent);
1032
+ });
1033
+
1034
+ _defineProperty(_assertThisInitialized(_this), "onPinchStart", function () {
1035
+ if (_this.enabled && _this.enableZoom) {
1036
+ _this.dispatchEvent(_startEvent);
1037
+
1038
+ _this.updateTbState(STATE.SCALE, true);
1039
+
1040
+ _this._startFingerDistance = _this.calculatePointersDistance(_this._touchCurrent[0], _this._touchCurrent[1]);
1041
+ _this._currentFingerDistance = _this._startFingerDistance;
1042
+
1043
+ _this.activateGizmos(false);
1044
+ }
1045
+ });
1046
+
1047
+ _defineProperty(_assertThisInitialized(_this), "onPinchMove", function () {
1048
+ if (_this.enabled && _this.enableZoom) {
1049
+ _this.setCenter((_this._touchCurrent[0].clientX + _this._touchCurrent[1].clientX) / 2, (_this._touchCurrent[0].clientY + _this._touchCurrent[1].clientY) / 2);
1050
+
1051
+ var minDistance = 12; //minimum distance between fingers (in css pixels)
1052
+
1053
+ if (_this._state != STATE.SCALE) {
1054
+ _this._startFingerDistance = _this._currentFingerDistance;
1055
+
1056
+ _this.updateTbState(STATE.SCALE, true);
1057
+ }
1058
+
1059
+ _this._currentFingerDistance = Math.max(_this.calculatePointersDistance(_this._touchCurrent[0], _this._touchCurrent[1]), minDistance * _this._devPxRatio);
1060
+ var amount = _this._currentFingerDistance / _this._startFingerDistance;
1061
+ var scalePoint;
1062
+
1063
+ if (!_this.enablePan) {
1064
+ scalePoint = _this._gizmos.position;
1065
+ } else {
1066
+ if (_this.camera.isOrthographicCamera) {
1067
+ scalePoint = _this.unprojectOnTbPlane(_this.camera, _center.x, _center.y, _this.domElement).applyQuaternion(_this.camera.quaternion).multiplyScalar(1 / _this.camera.zoom).add(_this._gizmos.position);
1068
+ } else if (_this.camera.isPerspectiveCamera) {
1069
+ scalePoint = _this.unprojectOnTbPlane(_this.camera, _center.x, _center.y, _this.domElement).applyQuaternion(_this.camera.quaternion).add(_this._gizmos.position);
1070
+ }
1071
+ }
1072
+
1073
+ _this.applyTransformMatrix(_this.scale(amount, scalePoint));
1074
+
1075
+ _this.dispatchEvent(_changeEvent);
1076
+ }
1077
+ });
1078
+
1079
+ _defineProperty(_assertThisInitialized(_this), "onPinchEnd", function () {
1080
+ _this.updateTbState(STATE.IDLE, false);
1081
+
1082
+ _this.dispatchEvent(_endEvent);
1083
+ });
1084
+
1085
+ _defineProperty(_assertThisInitialized(_this), "onTriplePanStart", function () {
1086
+ if (_this.enabled && _this.enableZoom) {
1087
+ _this.dispatchEvent(_startEvent);
1088
+
1089
+ _this.updateTbState(STATE.SCALE, true); //const center = event.center;
1090
+
1091
+
1092
+ var clientX = 0;
1093
+ var clientY = 0;
1094
+ var nFingers = _this._touchCurrent.length;
1095
+
1096
+ for (var i = 0; i < nFingers; i++) {
1097
+ clientX += _this._touchCurrent[i].clientX;
1098
+ clientY += _this._touchCurrent[i].clientY;
1099
+ }
1100
+
1101
+ _this.setCenter(clientX / nFingers, clientY / nFingers);
1102
+
1103
+ _this._startCursorPosition.setY(_this.getCursorNDC(_center.x, _center.y, _this.domElement).y * 0.5);
1104
+
1105
+ _this._currentCursorPosition.copy(_this._startCursorPosition);
1106
+ }
1107
+ });
1108
+
1109
+ _defineProperty(_assertThisInitialized(_this), "onTriplePanMove", function () {
1110
+ if (_this.enabled && _this.enableZoom) {
1111
+ // fov / 2
1112
+ // |\
1113
+ // | \
1114
+ // | \
1115
+ // x | \
1116
+ // | \
1117
+ // | \
1118
+ // | _ _ _\
1119
+ // y
1120
+ //const center = event.center;
1121
+ var clientX = 0;
1122
+ var clientY = 0;
1123
+ var nFingers = _this._touchCurrent.length;
1124
+
1125
+ for (var i = 0; i < nFingers; i++) {
1126
+ clientX += _this._touchCurrent[i].clientX;
1127
+ clientY += _this._touchCurrent[i].clientY;
1128
+ }
1129
+
1130
+ _this.setCenter(clientX / nFingers, clientY / nFingers);
1131
+
1132
+ var screenNotches = 8; //how many wheel notches corresponds to a full screen pan
1133
+
1134
+ _this._currentCursorPosition.setY(_this.getCursorNDC(_center.x, _center.y, _this.domElement).y * 0.5);
1135
+
1136
+ var movement = _this._currentCursorPosition.y - _this._startCursorPosition.y;
1137
+ var size = 1;
1138
+
1139
+ if (movement < 0) {
1140
+ size = 1 / Math.pow(_this.scaleFactor, -movement * screenNotches);
1141
+ } else if (movement > 0) {
1142
+ size = Math.pow(_this.scaleFactor, movement * screenNotches);
1143
+ }
1144
+
1145
+ _this._v3_1.setFromMatrixPosition(_this._cameraMatrixState);
1146
+
1147
+ var x = _this._v3_1.distanceTo(_this._gizmos.position);
1148
+
1149
+ var xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
1150
+ //check min and max distance
1151
+
1152
+ xNew = _three.MathUtils.clamp(xNew, _this.minDistance, _this.maxDistance);
1153
+ var y = x * Math.tan(_three.MathUtils.DEG2RAD * _this._fovState * 0.5); //calculate new fov
1154
+
1155
+ var newFov = _three.MathUtils.RAD2DEG * (Math.atan(y / xNew) * 2); //check min and max fov
1156
+
1157
+ newFov = _three.MathUtils.clamp(newFov, _this.minFov, _this.maxFov);
1158
+ var newDistance = y / Math.tan(_three.MathUtils.DEG2RAD * (newFov / 2));
1159
+ size = x / newDistance;
1160
+
1161
+ _this._v3_2.setFromMatrixPosition(_this._gizmoMatrixState);
1162
+
1163
+ _this.setFov(newFov);
1164
+
1165
+ _this.applyTransformMatrix(_this.scale(size, _this._v3_2, false)); //adjusting distance
1166
+
1167
+
1168
+ _offset.copy(_this._gizmos.position).sub(_this.camera.position).normalize().multiplyScalar(newDistance / x);
1169
+
1170
+ _this._m4_1.makeTranslation(_offset.x, _offset.y, _offset.z);
1171
+
1172
+ _this.dispatchEvent(_changeEvent);
1173
+ }
1174
+ });
1175
+
1176
+ _defineProperty(_assertThisInitialized(_this), "onTriplePanEnd", function () {
1177
+ _this.updateTbState(STATE.IDLE, false);
1178
+
1179
+ _this.dispatchEvent(_endEvent); //this.dispatchEvent( _changeEvent );
1180
+
1181
+ });
1182
+
1183
+ _defineProperty(_assertThisInitialized(_this), "setCenter", function (clientX, clientY) {
1184
+ _center.x = clientX;
1185
+ _center.y = clientY;
1186
+ });
1187
+
1188
+ _defineProperty(_assertThisInitialized(_this), "initializeMouseActions", function () {
1189
+ _this.setMouseAction('PAN', 0, 'CTRL');
1190
+
1191
+ _this.setMouseAction('PAN', 2);
1192
+
1193
+ _this.setMouseAction('ROTATE', 0);
1194
+
1195
+ _this.setMouseAction('ZOOM', 'WHEEL');
1196
+
1197
+ _this.setMouseAction('ZOOM', 1);
1198
+
1199
+ _this.setMouseAction('FOV', 'WHEEL', 'SHIFT');
1200
+
1201
+ _this.setMouseAction('FOV', 1, 'SHIFT');
1202
+ });
1203
+
1204
+ _defineProperty(_assertThisInitialized(_this), "compareMouseAction", function (action1, action2) {
1205
+ if (action1.operation == action2.operation) {
1206
+ if (action1.mouse == action2.mouse && action1.key == action2.key) {
1207
+ return true;
1208
+ } else {
1209
+ return false;
1210
+ }
1211
+ } else {
1212
+ return false;
1213
+ }
1214
+ });
1215
+
1216
+ _defineProperty(_assertThisInitialized(_this), "setMouseAction", function (operation, mouse) {
1217
+ var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1218
+ var operationInput = ['PAN', 'ROTATE', 'ZOOM', 'FOV'];
1219
+ var mouseInput = [0, 1, 2, 'WHEEL'];
1220
+ var keyInput = ['CTRL', 'SHIFT', null];
1221
+ var state;
1222
+
1223
+ if (!operationInput.includes(operation) || !mouseInput.includes(mouse) || !keyInput.includes(key)) {
1224
+ //invalid parameters
1225
+ return false;
1226
+ }
1227
+
1228
+ if (mouse == 'WHEEL') {
1229
+ if (operation != 'ZOOM' && operation != 'FOV') {
1230
+ //cannot associate 2D operation to 1D input
1231
+ return false;
1232
+ }
1233
+ }
1234
+
1235
+ switch (operation) {
1236
+ case 'PAN':
1237
+ state = STATE.PAN;
1238
+ break;
1239
+
1240
+ case 'ROTATE':
1241
+ state = STATE.ROTATE;
1242
+ break;
1243
+
1244
+ case 'ZOOM':
1245
+ state = STATE.SCALE;
1246
+ break;
1247
+
1248
+ case 'FOV':
1249
+ state = STATE.FOV;
1250
+ break;
1251
+ }
1252
+
1253
+ var action = {
1254
+ operation: operation,
1255
+ mouse: mouse,
1256
+ key: key,
1257
+ state: state
1258
+ };
1259
+
1260
+ for (var i = 0; i < _this.mouseActions.length; i++) {
1261
+ if (_this.mouseActions[i].mouse == action.mouse && _this.mouseActions[i].key == action.key) {
1262
+ _this.mouseActions.splice(i, 1, action);
1263
+
1264
+ return true;
1265
+ }
1266
+ }
1267
+
1268
+ _this.mouseActions.push(action);
1269
+
1270
+ return true;
1271
+ });
1272
+
1273
+ _defineProperty(_assertThisInitialized(_this), "unsetMouseAction", function (mouse) {
1274
+ var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1275
+
1276
+ for (var i = 0; i < _this.mouseActions.length; i++) {
1277
+ if (_this.mouseActions[i].mouse == mouse && _this.mouseActions[i].key == key) {
1278
+ _this.mouseActions.splice(i, 1);
1279
+
1280
+ return true;
1281
+ }
1282
+ }
1283
+
1284
+ return false;
1285
+ });
1286
+
1287
+ _defineProperty(_assertThisInitialized(_this), "getOpFromAction", function (mouse, key) {
1288
+ var action;
1289
+
1290
+ for (var i = 0; i < _this.mouseActions.length; i++) {
1291
+ action = _this.mouseActions[i];
1292
+
1293
+ if (action.mouse == mouse && action.key == key) {
1294
+ return action.operation;
1295
+ }
1296
+ }
1297
+
1298
+ if (key != null) {
1299
+ for (var _i = 0; _i < _this.mouseActions.length; _i++) {
1300
+ action = _this.mouseActions[_i];
1301
+
1302
+ if (action.mouse == mouse && action.key == null) {
1303
+ return action.operation;
1304
+ }
1305
+ }
1306
+ }
1307
+
1308
+ return null;
1309
+ });
1310
+
1311
+ _defineProperty(_assertThisInitialized(_this), "getOpStateFromAction", function (mouse, key) {
1312
+ var action;
1313
+
1314
+ for (var i = 0; i < _this.mouseActions.length; i++) {
1315
+ action = _this.mouseActions[i];
1316
+
1317
+ if (action.mouse == mouse && action.key == key) {
1318
+ return action.state;
1319
+ }
1320
+ }
1321
+
1322
+ if (key != null) {
1323
+ for (var _i2 = 0; _i2 < _this.mouseActions.length; _i2++) {
1324
+ action = _this.mouseActions[_i2];
1325
+
1326
+ if (action.mouse == mouse && action.key == null) {
1327
+ return action.state;
1328
+ }
1329
+ }
1330
+ }
1331
+
1332
+ return null;
1333
+ });
1334
+
1335
+ _defineProperty(_assertThisInitialized(_this), "getAngle", function (p1, p2) {
1336
+ return Math.atan2(p2.clientY - p1.clientY, p2.clientX - p1.clientX) * 180 / Math.PI;
1337
+ });
1338
+
1339
+ _defineProperty(_assertThisInitialized(_this), "updateTouchEvent", function (event) {
1340
+ for (var i = 0; i < _this._touchCurrent.length; i++) {
1341
+ if (_this._touchCurrent[i].pointerId == event.pointerId) {
1342
+ _this._touchCurrent.splice(i, 1, event);
1343
+
1344
+ break;
1345
+ }
1346
+ }
1347
+ });
1348
+
1349
+ _defineProperty(_assertThisInitialized(_this), "calculateAngularSpeed", function (p0, p1, t0, t1) {
1350
+ var s = p1 - p0;
1351
+ var t = (t1 - t0) / 1000;
1352
+
1353
+ if (t == 0) {
1354
+ return 0;
1355
+ }
1356
+
1357
+ return s / t;
1358
+ });
1359
+
1360
+ _defineProperty(_assertThisInitialized(_this), "calculatePointersDistance", function (p0, p1) {
1361
+ return Math.sqrt(Math.pow(p1.clientX - p0.clientX, 2) + Math.pow(p1.clientY - p0.clientY, 2));
1362
+ });
1363
+
1364
+ _defineProperty(_assertThisInitialized(_this), "calculateRotationAxis", function (vec1, vec2) {
1365
+ _this._rotationMatrix.extractRotation(_this._cameraMatrixState);
1366
+
1367
+ _this._quat.setFromRotationMatrix(_this._rotationMatrix);
1368
+
1369
+ _this._rotationAxis.crossVectors(vec1, vec2).applyQuaternion(_this._quat);
1370
+
1371
+ return _this._rotationAxis.normalize().clone();
1372
+ });
1373
+
1374
+ _defineProperty(_assertThisInitialized(_this), "calculateTbRadius", function (camera) {
1375
+ var distance = camera.position.distanceTo(_this._gizmos.position);
1376
+
1377
+ if (camera.type == 'PerspectiveCamera') {
1378
+ var halfFovV = _three.MathUtils.DEG2RAD * camera.fov * 0.5; //vertical fov/2 in radians
1379
+
1380
+ var halfFovH = Math.atan(camera.aspect * Math.tan(halfFovV)); //horizontal fov/2 in radians
1381
+
1382
+ return Math.tan(Math.min(halfFovV, halfFovH)) * distance * _this.radiusFactor;
1383
+ } else if (camera.type == 'OrthographicCamera') {
1384
+ return Math.min(camera.top, camera.right) * _this.radiusFactor;
1385
+ }
1386
+ });
1387
+
1388
+ _defineProperty(_assertThisInitialized(_this), "focus", function (point, size) {
1389
+ var amount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
1390
+
1391
+ //move center of camera (along with gizmos) towards point of interest
1392
+ _offset.copy(point).sub(_this._gizmos.position).multiplyScalar(amount);
1393
+
1394
+ _this._translationMatrix.makeTranslation(_offset.x, _offset.y, _offset.z);
1395
+
1396
+ var gizmoStateTemp = _this._gizmoMatrixState.clone();
1397
+
1398
+ _this._gizmoMatrixState.premultiply(_this._translationMatrix);
1399
+
1400
+ _this._gizmoMatrixState.decompose(_this._gizmos.position, _this._gizmos.quaternion, _this._gizmos.scale);
1401
+
1402
+ var cameraStateTemp = _this._cameraMatrixState.clone();
1403
+
1404
+ _this._cameraMatrixState.premultiply(_this._translationMatrix);
1405
+
1406
+ _this._cameraMatrixState.decompose(_this.camera.position, _this.camera.quaternion, _this.camera.scale); //apply zoom
1407
+
1408
+
1409
+ if (_this.enableZoom) {
1410
+ _this.applyTransformMatrix(_this.scale(size, _this._gizmos.position));
1411
+ }
1412
+
1413
+ _this._gizmoMatrixState.copy(gizmoStateTemp);
1414
+
1415
+ _this._cameraMatrixState.copy(cameraStateTemp);
1416
+ });
1417
+
1418
+ _defineProperty(_assertThisInitialized(_this), "drawGrid", function () {
1419
+ if (_this.scene != null) {
1420
+ var color = 0x888888;
1421
+ var multiplier = 3;
1422
+ var size, divisions, maxLength, tick;
1423
+
1424
+ if (_this.camera.isOrthographicCamera) {
1425
+ var width = _this.camera.right - _this.camera.left;
1426
+ var height = _this.camera.bottom - _this.camera.top;
1427
+ maxLength = Math.max(width, height);
1428
+ tick = maxLength / 20;
1429
+ size = maxLength / _this.camera.zoom * multiplier;
1430
+ divisions = size / tick * _this.camera.zoom;
1431
+ } else if (_this.camera.isPerspectiveCamera) {
1432
+ var distance = _this.camera.position.distanceTo(_this._gizmos.position);
1433
+
1434
+ var halfFovV = _three.MathUtils.DEG2RAD * _this.camera.fov * 0.5;
1435
+ var halfFovH = Math.atan(_this.camera.aspect * Math.tan(halfFovV));
1436
+ maxLength = Math.tan(Math.max(halfFovV, halfFovH)) * distance * 2;
1437
+ tick = maxLength / 20;
1438
+ size = maxLength * multiplier;
1439
+ divisions = size / tick;
1440
+ }
1441
+
1442
+ if (_this._grid == null) {
1443
+ _this._grid = new _three.GridHelper(size, divisions, color, color);
1444
+
1445
+ _this._grid.position.copy(_this._gizmos.position);
1446
+
1447
+ _this._gridPosition.copy(_this._grid.position);
1448
+
1449
+ _this._grid.quaternion.copy(_this.camera.quaternion);
1450
+
1451
+ _this._grid.rotateX(Math.PI * 0.5);
1452
+
1453
+ _this.scene.add(_this._grid);
1454
+ }
1455
+ }
1456
+ });
1457
+
1458
+ _defineProperty(_assertThisInitialized(_this), "dispose", function () {
1459
+ if (_this._animationId != -1) {
1460
+ window.cancelAnimationFrame(_this._animationId);
1461
+ }
1462
+
1463
+ _this.domElement.removeEventListener('pointerdown', _this.onPointerDown);
1464
+
1465
+ _this.domElement.removeEventListener('pointercancel', _this.onPointerCancel);
1466
+
1467
+ _this.domElement.removeEventListener('wheel', _this.onWheel);
1468
+
1469
+ _this.domElement.removeEventListener('contextmenu', _this.onContextMenu);
1470
+
1471
+ window.removeEventListener('pointermove', _this.onPointerMove);
1472
+ window.removeEventListener('pointerup', _this.onPointerUp);
1473
+ window.removeEventListener('resize', _this.onWindowResize);
1474
+ window.removeEventListener('keydown', _this.onKeyDown);
1475
+ if (_this.scene !== null) _this.scene.remove(_this._gizmos);
1476
+
1477
+ _this.disposeGrid();
1478
+ });
1479
+
1480
+ _defineProperty(_assertThisInitialized(_this), "disposeGrid", function () {
1481
+ if (_this._grid != null && _this.scene != null) {
1482
+ _this.scene.remove(_this._grid);
1483
+
1484
+ _this._grid = null;
1485
+ }
1486
+ });
1487
+
1488
+ _defineProperty(_assertThisInitialized(_this), "easeOutCubic", function (t) {
1489
+ return 1 - Math.pow(1 - t, 3);
1490
+ });
1491
+
1492
+ _defineProperty(_assertThisInitialized(_this), "activateGizmos", function (isActive) {
1493
+ var gizmoX = _this._gizmos.children[0];
1494
+ var gizmoY = _this._gizmos.children[1];
1495
+ var gizmoZ = _this._gizmos.children[2];
1496
+
1497
+ if (isActive) {
1498
+ gizmoX.material.setValues({
1499
+ opacity: 1
1500
+ });
1501
+ gizmoY.material.setValues({
1502
+ opacity: 1
1503
+ });
1504
+ gizmoZ.material.setValues({
1505
+ opacity: 1
1506
+ });
1507
+ } else {
1508
+ gizmoX.material.setValues({
1509
+ opacity: 0.6
1510
+ });
1511
+ gizmoY.material.setValues({
1512
+ opacity: 0.6
1513
+ });
1514
+ gizmoZ.material.setValues({
1515
+ opacity: 0.6
1516
+ });
1517
+ }
1518
+ });
1519
+
1520
+ _defineProperty(_assertThisInitialized(_this), "getCursorNDC", function (cursorX, cursorY, canvas) {
1521
+ var canvasRect = canvas.getBoundingClientRect();
1522
+
1523
+ _this._v2_1.setX((cursorX - canvasRect.left) / canvasRect.width * 2 - 1);
1524
+
1525
+ _this._v2_1.setY((canvasRect.bottom - cursorY) / canvasRect.height * 2 - 1);
1526
+
1527
+ return _this._v2_1.clone();
1528
+ });
1529
+
1530
+ _defineProperty(_assertThisInitialized(_this), "getCursorPosition", function (cursorX, cursorY, canvas) {
1531
+ _this._v2_1.copy(_this.getCursorNDC(cursorX, cursorY, canvas));
1532
+
1533
+ _this._v2_1.x *= (_this.camera.right - _this.camera.left) * 0.5;
1534
+ _this._v2_1.y *= (_this.camera.top - _this.camera.bottom) * 0.5;
1535
+ return _this._v2_1.clone();
1536
+ });
1537
+
1538
+ _defineProperty(_assertThisInitialized(_this), "setCamera", function (camera) {
1539
+ camera.lookAt(_this.target);
1540
+ camera.updateMatrix(); //setting state
1541
+
1542
+ if (camera.type == 'PerspectiveCamera') {
1543
+ _this._fov0 = camera.fov;
1544
+ _this._fovState = camera.fov;
1545
+ }
1546
+
1547
+ _this._cameraMatrixState0.copy(camera.matrix);
1548
+
1549
+ _this._cameraMatrixState.copy(_this._cameraMatrixState0);
1550
+
1551
+ _this._cameraProjectionState.copy(camera.projectionMatrix);
1552
+
1553
+ _this._zoom0 = camera.zoom;
1554
+ _this._zoomState = _this._zoom0;
1555
+ _this._initialNear = camera.near;
1556
+ _this._nearPos0 = camera.position.distanceTo(_this.target) - camera.near;
1557
+ _this._nearPos = _this._initialNear;
1558
+ _this._initialFar = camera.far;
1559
+ _this._farPos0 = camera.position.distanceTo(_this.target) - camera.far;
1560
+ _this._farPos = _this._initialFar;
1561
+
1562
+ _this._up0.copy(camera.up);
1563
+
1564
+ _this._upState.copy(camera.up);
1565
+
1566
+ _this.camera = camera;
1567
+
1568
+ _this.camera.updateProjectionMatrix(); //making gizmos
1569
+
1570
+
1571
+ _this._tbRadius = _this.calculateTbRadius(camera);
1572
+
1573
+ _this.makeGizmos(_this.target, _this._tbRadius);
1574
+ });
1575
+
1576
+ _defineProperty(_assertThisInitialized(_this), "makeGizmos", function (tbCenter, tbRadius) {
1577
+ var curve = new _three.EllipseCurve(0, 0, tbRadius, tbRadius);
1578
+ var points = curve.getPoints(_this._curvePts); //geometry
1579
+
1580
+ var curveGeometry = new _three.BufferGeometry().setFromPoints(points); //material
1581
+
1582
+ var curveMaterialX = new _three.LineBasicMaterial({
1583
+ color: 0xff8080,
1584
+ fog: false,
1585
+ transparent: true,
1586
+ opacity: 0.6
1587
+ });
1588
+ var curveMaterialY = new _three.LineBasicMaterial({
1589
+ color: 0x80ff80,
1590
+ fog: false,
1591
+ transparent: true,
1592
+ opacity: 0.6
1593
+ });
1594
+ var curveMaterialZ = new _three.LineBasicMaterial({
1595
+ color: 0x8080ff,
1596
+ fog: false,
1597
+ transparent: true,
1598
+ opacity: 0.6
1599
+ }); //line
1600
+
1601
+ var gizmoX = new _three.Line(curveGeometry, curveMaterialX);
1602
+ var gizmoY = new _three.Line(curveGeometry, curveMaterialY);
1603
+ var gizmoZ = new _three.Line(curveGeometry, curveMaterialZ);
1604
+ var rotation = Math.PI * 0.5;
1605
+ gizmoX.rotation.x = rotation;
1606
+ gizmoY.rotation.y = rotation; //setting state
1607
+
1608
+ _this._gizmoMatrixState0.identity().setPosition(tbCenter);
1609
+
1610
+ _this._gizmoMatrixState.copy(_this._gizmoMatrixState0);
1611
+
1612
+ if (_this.camera.zoom != 1) {
1613
+ //adapt gizmos size to camera zoom
1614
+ var size = 1 / _this.camera.zoom;
1615
+
1616
+ _this._scaleMatrix.makeScale(size, size, size);
1617
+
1618
+ _this._translationMatrix.makeTranslation(-tbCenter.x, -tbCenter.y, -tbCenter.z);
1619
+
1620
+ _this._gizmoMatrixState.premultiply(_this._translationMatrix).premultiply(_this._scaleMatrix);
1621
+
1622
+ _this._translationMatrix.makeTranslation(tbCenter.x, tbCenter.y, tbCenter.z);
1623
+
1624
+ _this._gizmoMatrixState.premultiply(_this._translationMatrix);
1625
+ }
1626
+
1627
+ _this._gizmoMatrixState.decompose(_this._gizmos.position, _this._gizmos.quaternion, _this._gizmos.scale);
1628
+
1629
+ _this._gizmos.clear();
1630
+
1631
+ _this._gizmos.add(gizmoX);
1632
+
1633
+ _this._gizmos.add(gizmoY);
1634
+
1635
+ _this._gizmos.add(gizmoZ);
1636
+ });
1637
+
1638
+ _defineProperty(_assertThisInitialized(_this), "onFocusAnim", function (time, point, cameraMatrix, gizmoMatrix) {
1639
+ if (_this._timeStart == -1) {
1640
+ //animation start
1641
+ _this._timeStart = time;
1642
+ }
1643
+
1644
+ if (_this._state == STATE.ANIMATION_FOCUS) {
1645
+ var deltaTime = time - _this._timeStart;
1646
+ var animTime = deltaTime / _this.focusAnimationTime;
1647
+
1648
+ _this._gizmoMatrixState.copy(gizmoMatrix);
1649
+
1650
+ if (animTime >= 1) {
1651
+ //animation end
1652
+ _this._gizmoMatrixState.decompose(_this._gizmos.position, _this._gizmos.quaternion, _this._gizmos.scale);
1653
+
1654
+ _this.focus(point, _this.scaleFactor);
1655
+
1656
+ _this._timeStart = -1;
1657
+
1658
+ _this.updateTbState(STATE.IDLE, false);
1659
+
1660
+ _this.activateGizmos(false);
1661
+
1662
+ _this.dispatchEvent(_changeEvent);
1663
+ } else {
1664
+ var amount = _this.easeOutCubic(animTime);
1665
+
1666
+ var size = 1 - amount + _this.scaleFactor * amount;
1667
+
1668
+ _this._gizmoMatrixState.decompose(_this._gizmos.position, _this._gizmos.quaternion, _this._gizmos.scale);
1669
+
1670
+ _this.focus(point, size, amount);
1671
+
1672
+ _this.dispatchEvent(_changeEvent);
1673
+
1674
+ var self = _assertThisInitialized(_this);
1675
+
1676
+ _this._animationId = window.requestAnimationFrame(function (t) {
1677
+ self.onFocusAnim(t, point, cameraMatrix, gizmoMatrix.clone());
1678
+ });
1679
+ }
1680
+ } else {
1681
+ //interrupt animation
1682
+ _this._animationId = -1;
1683
+ _this._timeStart = -1;
1684
+ }
1685
+ });
1686
+
1687
+ _defineProperty(_assertThisInitialized(_this), "onRotationAnim", function (time, rotationAxis, w0) {
1688
+ if (_this._timeStart == -1) {
1689
+ //animation start
1690
+ _this._anglePrev = 0;
1691
+ _this._angleCurrent = 0;
1692
+ _this._timeStart = time;
1693
+ }
1694
+
1695
+ if (_this._state == STATE.ANIMATION_ROTATE) {
1696
+ //w = w0 + alpha * t
1697
+ var deltaTime = (time - _this._timeStart) / 1000;
1698
+ var w = w0 + -_this.dampingFactor * deltaTime;
1699
+
1700
+ if (w > 0) {
1701
+ //tetha = 0.5 * alpha * t^2 + w0 * t + tetha0
1702
+ _this._angleCurrent = 0.5 * -_this.dampingFactor * Math.pow(deltaTime, 2) + w0 * deltaTime + 0;
1703
+
1704
+ _this.applyTransformMatrix(_this.rotate(rotationAxis, _this._angleCurrent));
1705
+
1706
+ _this.dispatchEvent(_changeEvent);
1707
+
1708
+ var self = _assertThisInitialized(_this);
1709
+
1710
+ _this._animationId = window.requestAnimationFrame(function (t) {
1711
+ self.onRotationAnim(t, rotationAxis, w0);
1712
+ });
1713
+ } else {
1714
+ _this._animationId = -1;
1715
+ _this._timeStart = -1;
1716
+
1717
+ _this.updateTbState(STATE.IDLE, false);
1718
+
1719
+ _this.activateGizmos(false);
1720
+
1721
+ _this.dispatchEvent(_changeEvent);
1722
+ }
1723
+ } else {
1724
+ //interrupt animation
1725
+ _this._animationId = -1;
1726
+ _this._timeStart = -1;
1727
+
1728
+ if (_this._state != STATE.ROTATE) {
1729
+ _this.activateGizmos(false);
1730
+
1731
+ _this.dispatchEvent(_changeEvent);
1732
+ }
1733
+ }
1734
+ });
1735
+
1736
+ _defineProperty(_assertThisInitialized(_this), "pan", function (p0, p1) {
1737
+ var adjust = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1738
+ var movement = p0.clone().sub(p1);
1739
+
1740
+ if (_this.camera.isOrthographicCamera) {
1741
+ //adjust movement amount
1742
+ movement.multiplyScalar(1 / _this.camera.zoom);
1743
+ } else if (_this.camera.isPerspectiveCamera && adjust) {
1744
+ //adjust movement amount
1745
+ _this._v3_1.setFromMatrixPosition(_this._cameraMatrixState0); //camera's initial position
1746
+
1747
+
1748
+ _this._v3_2.setFromMatrixPosition(_this._gizmoMatrixState0); //gizmo's initial position
1749
+
1750
+
1751
+ var distanceFactor = _this._v3_1.distanceTo(_this._v3_2) / _this.camera.position.distanceTo(_this._gizmos.position);
1752
+
1753
+ movement.multiplyScalar(1 / distanceFactor);
1754
+ }
1755
+
1756
+ _this._v3_1.set(movement.x, movement.y, 0).applyQuaternion(_this.camera.quaternion);
1757
+
1758
+ _this._m4_1.makeTranslation(_this._v3_1.x, _this._v3_1.y, _this._v3_1.z);
1759
+
1760
+ _this.setTransformationMatrices(_this._m4_1, _this._m4_1);
1761
+
1762
+ return _transformation;
1763
+ });
1764
+
1765
+ _defineProperty(_assertThisInitialized(_this), "reset", function () {
1766
+ _this.camera.zoom = _this._zoom0;
1767
+
1768
+ if (_this.camera.isPerspectiveCamera) {
1769
+ _this.camera.fov = _this._fov0;
1770
+ }
1771
+
1772
+ _this.camera.near = _this._nearPos;
1773
+ _this.camera.far = _this._farPos;
1774
+
1775
+ _this._cameraMatrixState.copy(_this._cameraMatrixState0);
1776
+
1777
+ _this._cameraMatrixState.decompose(_this.camera.position, _this.camera.quaternion, _this.camera.scale);
1778
+
1779
+ _this.camera.up.copy(_this._up0);
1780
+
1781
+ _this.camera.updateMatrix();
1782
+
1783
+ _this.camera.updateProjectionMatrix();
1784
+
1785
+ _this._gizmoMatrixState.copy(_this._gizmoMatrixState0);
1786
+
1787
+ _this._gizmoMatrixState0.decompose(_this._gizmos.position, _this._gizmos.quaternion, _this._gizmos.scale);
1788
+
1789
+ _this._gizmos.updateMatrix();
1790
+
1791
+ _this._tbRadius = _this.calculateTbRadius(_this.camera);
1792
+
1793
+ _this.makeGizmos(_this._gizmos.position, _this._tbRadius);
1794
+
1795
+ _this.camera.lookAt(_this._gizmos.position);
1796
+
1797
+ _this.updateTbState(STATE.IDLE, false);
1798
+
1799
+ _this.dispatchEvent(_changeEvent);
1800
+ });
1801
+
1802
+ _defineProperty(_assertThisInitialized(_this), "rotate", function (axis, angle) {
1803
+ var point = _this._gizmos.position; //rotation center
1804
+
1805
+ _this._translationMatrix.makeTranslation(-point.x, -point.y, -point.z);
1806
+
1807
+ _this._rotationMatrix.makeRotationAxis(axis, -angle); //rotate camera
1808
+
1809
+
1810
+ _this._m4_1.makeTranslation(point.x, point.y, point.z);
1811
+
1812
+ _this._m4_1.multiply(_this._rotationMatrix);
1813
+
1814
+ _this._m4_1.multiply(_this._translationMatrix);
1815
+
1816
+ _this.setTransformationMatrices(_this._m4_1);
1817
+
1818
+ return _transformation;
1819
+ });
1820
+
1821
+ _defineProperty(_assertThisInitialized(_this), "copyState", function () {
1822
+ var state;
1823
+
1824
+ if (_this.camera.isOrthographicCamera) {
1825
+ state = JSON.stringify({
1826
+ arcballState: {
1827
+ cameraFar: _this.camera.far,
1828
+ cameraMatrix: _this.camera.matrix,
1829
+ cameraNear: _this.camera.near,
1830
+ cameraUp: _this.camera.up,
1831
+ cameraZoom: _this.camera.zoom,
1832
+ gizmoMatrix: _this._gizmos.matrix
1833
+ }
1834
+ });
1835
+ } else if (_this.camera.isPerspectiveCamera) {
1836
+ state = JSON.stringify({
1837
+ arcballState: {
1838
+ cameraFar: _this.camera.far,
1839
+ cameraFov: _this.camera.fov,
1840
+ cameraMatrix: _this.camera.matrix,
1841
+ cameraNear: _this.camera.near,
1842
+ cameraUp: _this.camera.up,
1843
+ cameraZoom: _this.camera.zoom,
1844
+ gizmoMatrix: _this._gizmos.matrix
1845
+ }
1846
+ });
1847
+ }
1848
+
1849
+ navigator.clipboard.writeText(state);
1850
+ });
1851
+
1852
+ _defineProperty(_assertThisInitialized(_this), "pasteState", function () {
1853
+ var self = _assertThisInitialized(_this);
1854
+
1855
+ navigator.clipboard.readText().then(function resolved(value) {
1856
+ self.setStateFromJSON(value);
1857
+ });
1858
+ });
1859
+
1860
+ _defineProperty(_assertThisInitialized(_this), "saveState", function () {
1861
+ _this._cameraMatrixState0.copy(_this.camera.matrix);
1862
+
1863
+ _this._gizmoMatrixState0.copy(_this._gizmos.matrix);
1864
+
1865
+ _this._nearPos = _this.camera.near;
1866
+ _this._farPos = _this.camera.far;
1867
+ _this._zoom0 = _this.camera.zoom;
1868
+
1869
+ _this._up0.copy(_this.camera.up);
1870
+
1871
+ if (_this.camera.isPerspectiveCamera) {
1872
+ _this._fov0 = _this.camera.fov;
1873
+ }
1874
+ });
1875
+
1876
+ _defineProperty(_assertThisInitialized(_this), "scale", function (size, point) {
1877
+ var scaleGizmos = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
1878
+ var scalePoint = point.clone();
1879
+ var sizeInverse = 1 / size;
1880
+
1881
+ if (_this.camera.isOrthographicCamera) {
1882
+ //camera zoom
1883
+ _this.camera.zoom = _this._zoomState;
1884
+ _this.camera.zoom *= size; //check min and max zoom
1885
+
1886
+ if (_this.camera.zoom > _this.maxZoom) {
1887
+ _this.camera.zoom = _this.maxZoom;
1888
+ sizeInverse = _this._zoomState / _this.maxZoom;
1889
+ } else if (_this.camera.zoom < _this.minZoom) {
1890
+ _this.camera.zoom = _this.minZoom;
1891
+ sizeInverse = _this._zoomState / _this.minZoom;
1892
+ }
1893
+
1894
+ _this.camera.updateProjectionMatrix();
1895
+
1896
+ _this._v3_1.setFromMatrixPosition(_this._gizmoMatrixState); //gizmos position
1897
+ //scale gizmos so they appear in the same spot having the same dimension
1898
+
1899
+
1900
+ _this._scaleMatrix.makeScale(sizeInverse, sizeInverse, sizeInverse);
1901
+
1902
+ _this._translationMatrix.makeTranslation(-_this._v3_1.x, -_this._v3_1.y, -_this._v3_1.z);
1903
+
1904
+ _this._m4_2.makeTranslation(_this._v3_1.x, _this._v3_1.y, _this._v3_1.z).multiply(_this._scaleMatrix);
1905
+
1906
+ _this._m4_2.multiply(_this._translationMatrix); //move camera and gizmos to obtain pinch effect
1907
+
1908
+
1909
+ scalePoint.sub(_this._v3_1);
1910
+ var amount = scalePoint.clone().multiplyScalar(sizeInverse);
1911
+ scalePoint.sub(amount);
1912
+
1913
+ _this._m4_1.makeTranslation(scalePoint.x, scalePoint.y, scalePoint.z);
1914
+
1915
+ _this._m4_2.premultiply(_this._m4_1);
1916
+
1917
+ _this.setTransformationMatrices(_this._m4_1, _this._m4_2);
1918
+
1919
+ return _transformation;
1920
+ } else if (_this.camera.isPerspectiveCamera) {
1921
+ _this._v3_1.setFromMatrixPosition(_this._cameraMatrixState);
1922
+
1923
+ _this._v3_2.setFromMatrixPosition(_this._gizmoMatrixState); //move camera
1924
+
1925
+
1926
+ var distance = _this._v3_1.distanceTo(scalePoint);
1927
+
1928
+ var _amount = distance - distance * sizeInverse; //check min and max distance
1929
+
1930
+
1931
+ var newDistance = distance - _amount;
1932
+
1933
+ if (newDistance < _this.minDistance) {
1934
+ sizeInverse = _this.minDistance / distance;
1935
+ _amount = distance - distance * sizeInverse;
1936
+ } else if (newDistance > _this.maxDistance) {
1937
+ sizeInverse = _this.maxDistance / distance;
1938
+ _amount = distance - distance * sizeInverse;
1939
+ }
1940
+
1941
+ _offset.copy(scalePoint).sub(_this._v3_1).normalize().multiplyScalar(_amount);
1942
+
1943
+ _this._m4_1.makeTranslation(_offset.x, _offset.y, _offset.z);
1944
+
1945
+ if (scaleGizmos) {
1946
+ //scale gizmos so they appear in the same spot having the same dimension
1947
+ var pos = _this._v3_2;
1948
+ distance = pos.distanceTo(scalePoint);
1949
+ _amount = distance - distance * sizeInverse;
1950
+
1951
+ _offset.copy(scalePoint).sub(_this._v3_2).normalize().multiplyScalar(_amount);
1952
+
1953
+ _this._translationMatrix.makeTranslation(pos.x, pos.y, pos.z);
1954
+
1955
+ _this._scaleMatrix.makeScale(sizeInverse, sizeInverse, sizeInverse);
1956
+
1957
+ _this._m4_2.makeTranslation(_offset.x, _offset.y, _offset.z).multiply(_this._translationMatrix);
1958
+
1959
+ _this._m4_2.multiply(_this._scaleMatrix);
1960
+
1961
+ _this._translationMatrix.makeTranslation(-pos.x, -pos.y, -pos.z);
1962
+
1963
+ _this._m4_2.multiply(_this._translationMatrix);
1964
+
1965
+ _this.setTransformationMatrices(_this._m4_1, _this._m4_2);
1966
+ } else {
1967
+ _this.setTransformationMatrices(_this._m4_1);
1968
+ }
1969
+
1970
+ return _transformation;
1971
+ }
1972
+ });
1973
+
1974
+ _defineProperty(_assertThisInitialized(_this), "setFov", function (value) {
1975
+ if (_this.camera.isPerspectiveCamera) {
1976
+ _this.camera.fov = _three.MathUtils.clamp(value, _this.minFov, _this.maxFov);
1977
+
1978
+ _this.camera.updateProjectionMatrix();
1979
+ }
1980
+ });
1981
+
1982
+ _defineProperty(_assertThisInitialized(_this), "setTarget", function (x, y, z) {
1983
+ _this.target.set(x, y, z);
1984
+
1985
+ _this._gizmos.position.set(x, y, z); //for correct radius calculation
1986
+
1987
+
1988
+ _this._tbRadius = _this.calculateTbRadius(_this.camera);
1989
+
1990
+ _this.makeGizmos(_this.target, _this._tbRadius);
1991
+
1992
+ _this.camera.lookAt(_this.target);
1993
+ });
1994
+
1995
+ _defineProperty(_assertThisInitialized(_this), "zRotate", function (point, angle) {
1996
+ _this._rotationMatrix.makeRotationAxis(_this._rotationAxis, angle);
1997
+
1998
+ _this._translationMatrix.makeTranslation(-point.x, -point.y, -point.z);
1999
+
2000
+ _this._m4_1.makeTranslation(point.x, point.y, point.z);
2001
+
2002
+ _this._m4_1.multiply(_this._rotationMatrix);
2003
+
2004
+ _this._m4_1.multiply(_this._translationMatrix);
2005
+
2006
+ _this._v3_1.setFromMatrixPosition(_this._gizmoMatrixState).sub(point); //vector from rotation center to gizmos position
2007
+
2008
+
2009
+ _this._v3_2.copy(_this._v3_1).applyAxisAngle(_this._rotationAxis, angle); //apply rotation
2010
+
2011
+
2012
+ _this._v3_2.sub(_this._v3_1);
2013
+
2014
+ _this._m4_2.makeTranslation(_this._v3_2.x, _this._v3_2.y, _this._v3_2.z);
2015
+
2016
+ _this.setTransformationMatrices(_this._m4_1, _this._m4_2);
2017
+
2018
+ return _transformation;
2019
+ });
2020
+
2021
+ _defineProperty(_assertThisInitialized(_this), "unprojectOnObj", function (cursor, camera) {
2022
+ var raycaster = _this.getRaycaster();
2023
+
2024
+ raycaster.near = camera.near;
2025
+ raycaster.far = camera.far;
2026
+ raycaster.setFromCamera(cursor, camera);
2027
+ var intersect = raycaster.intersectObjects(_this.scene.children, true);
2028
+
2029
+ for (var i = 0; i < intersect.length; i++) {
2030
+ if (intersect[i].object.uuid != _this._gizmos.uuid && intersect[i].face != null) {
2031
+ return intersect[i].point.clone();
2032
+ }
2033
+ }
2034
+
2035
+ return null;
2036
+ });
2037
+
2038
+ _defineProperty(_assertThisInitialized(_this), "unprojectOnTbSurface", function (camera, cursorX, cursorY, canvas, tbRadius) {
2039
+ if (camera.type == 'OrthographicCamera') {
2040
+ _this._v2_1.copy(_this.getCursorPosition(cursorX, cursorY, canvas));
2041
+
2042
+ _this._v3_1.set(_this._v2_1.x, _this._v2_1.y, 0);
2043
+
2044
+ var x2 = Math.pow(_this._v2_1.x, 2);
2045
+ var y2 = Math.pow(_this._v2_1.y, 2);
2046
+ var r2 = Math.pow(_this._tbRadius, 2);
2047
+
2048
+ if (x2 + y2 <= r2 * 0.5) {
2049
+ //intersection with sphere
2050
+ _this._v3_1.setZ(Math.sqrt(r2 - (x2 + y2)));
2051
+ } else {
2052
+ //intersection with hyperboloid
2053
+ _this._v3_1.setZ(r2 * 0.5 / Math.sqrt(x2 + y2));
2054
+ }
2055
+
2056
+ return _this._v3_1;
2057
+ } else if (camera.type == 'PerspectiveCamera') {
2058
+ //unproject cursor on the near plane
2059
+ _this._v2_1.copy(_this.getCursorNDC(cursorX, cursorY, canvas));
2060
+
2061
+ _this._v3_1.set(_this._v2_1.x, _this._v2_1.y, -1);
2062
+
2063
+ _this._v3_1.applyMatrix4(camera.projectionMatrixInverse);
2064
+
2065
+ var rayDir = _this._v3_1.clone().normalize(); //unprojected ray direction
2066
+
2067
+
2068
+ var cameraGizmoDistance = camera.position.distanceTo(_this._gizmos.position);
2069
+ var radius2 = Math.pow(tbRadius, 2); // camera
2070
+ // |\
2071
+ // | \
2072
+ // | \
2073
+ // h | \
2074
+ // | \
2075
+ // | \
2076
+ // _ _ | _ _ _\ _ _ near plane
2077
+ // l
2078
+
2079
+ var h = _this._v3_1.z;
2080
+ var l = Math.sqrt(Math.pow(_this._v3_1.x, 2) + Math.pow(_this._v3_1.y, 2));
2081
+
2082
+ if (l == 0) {
2083
+ //ray aligned with camera
2084
+ rayDir.set(_this._v3_1.x, _this._v3_1.y, tbRadius);
2085
+ return rayDir;
2086
+ }
2087
+
2088
+ var m = h / l;
2089
+ var q = cameraGizmoDistance;
2090
+ /*
2091
+ * calculate intersection point between unprojected ray and trackball surface
2092
+ *|y = m * x + q
2093
+ *|x^2 + y^2 = r^2
2094
+ *
2095
+ * (m^2 + 1) * x^2 + (2 * m * q) * x + q^2 - r^2 = 0
2096
+ */
2097
+
2098
+ var a = Math.pow(m, 2) + 1;
2099
+ var b = 2 * m * q;
2100
+ var c = Math.pow(q, 2) - radius2;
2101
+ var delta = Math.pow(b, 2) - 4 * a * c;
2102
+
2103
+ if (delta >= 0) {
2104
+ //intersection with sphere
2105
+ _this._v2_1.setX((-b - Math.sqrt(delta)) / (2 * a));
2106
+
2107
+ _this._v2_1.setY(m * _this._v2_1.x + q);
2108
+
2109
+ var angle = _three.MathUtils.RAD2DEG * _this._v2_1.angle();
2110
+
2111
+ if (angle >= 45) {
2112
+ //if angle between intersection point and X' axis is >= 45°, return that point
2113
+ //otherwise, calculate intersection point with hyperboloid
2114
+ var _rayLength = Math.sqrt(Math.pow(_this._v2_1.x, 2) + Math.pow(cameraGizmoDistance - _this._v2_1.y, 2));
2115
+
2116
+ rayDir.multiplyScalar(_rayLength);
2117
+ rayDir.z += cameraGizmoDistance;
2118
+ return rayDir;
2119
+ }
2120
+ } //intersection with hyperboloid
2121
+
2122
+ /*
2123
+ *|y = m * x + q
2124
+ *|y = (1 / x) * (r^2 / 2)
2125
+ *
2126
+ * m * x^2 + q * x - r^2 / 2 = 0
2127
+ */
2128
+
2129
+
2130
+ a = m;
2131
+ b = q;
2132
+ c = -radius2 * 0.5;
2133
+ delta = Math.pow(b, 2) - 4 * a * c;
2134
+
2135
+ _this._v2_1.setX((-b - Math.sqrt(delta)) / (2 * a));
2136
+
2137
+ _this._v2_1.setY(m * _this._v2_1.x + q);
2138
+
2139
+ var rayLength = Math.sqrt(Math.pow(_this._v2_1.x, 2) + Math.pow(cameraGizmoDistance - _this._v2_1.y, 2));
2140
+ rayDir.multiplyScalar(rayLength);
2141
+ rayDir.z += cameraGizmoDistance;
2142
+ return rayDir;
2143
+ }
2144
+ });
2145
+
2146
+ _defineProperty(_assertThisInitialized(_this), "unprojectOnTbPlane", function (camera, cursorX, cursorY, canvas) {
2147
+ var initialDistance = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
2148
+
2149
+ if (camera.type == 'OrthographicCamera') {
2150
+ _this._v2_1.copy(_this.getCursorPosition(cursorX, cursorY, canvas));
2151
+
2152
+ _this._v3_1.set(_this._v2_1.x, _this._v2_1.y, 0);
2153
+
2154
+ return _this._v3_1.clone();
2155
+ } else if (camera.type == 'PerspectiveCamera') {
2156
+ _this._v2_1.copy(_this.getCursorNDC(cursorX, cursorY, canvas)); //unproject cursor on the near plane
2157
+
2158
+
2159
+ _this._v3_1.set(_this._v2_1.x, _this._v2_1.y, -1);
2160
+
2161
+ _this._v3_1.applyMatrix4(camera.projectionMatrixInverse);
2162
+
2163
+ var rayDir = _this._v3_1.clone().normalize(); //unprojected ray direction
2164
+ // camera
2165
+ // |\
2166
+ // | \
2167
+ // | \
2168
+ // h | \
2169
+ // | \
2170
+ // | \
2171
+ // _ _ | _ _ _\ _ _ near plane
2172
+ // l
2173
+
2174
+
2175
+ var h = _this._v3_1.z;
2176
+ var l = Math.sqrt(Math.pow(_this._v3_1.x, 2) + Math.pow(_this._v3_1.y, 2));
2177
+ var cameraGizmoDistance;
2178
+
2179
+ if (initialDistance) {
2180
+ cameraGizmoDistance = _this._v3_1.setFromMatrixPosition(_this._cameraMatrixState0).distanceTo(_this._v3_2.setFromMatrixPosition(_this._gizmoMatrixState0));
2181
+ } else {
2182
+ cameraGizmoDistance = camera.position.distanceTo(_this._gizmos.position);
2183
+ }
2184
+ /*
2185
+ * calculate intersection point between unprojected ray and the plane
2186
+ *|y = mx + q
2187
+ *|y = 0
2188
+ *
2189
+ * x = -q/m
2190
+ */
2191
+
2192
+
2193
+ if (l == 0) {
2194
+ //ray aligned with camera
2195
+ rayDir.set(0, 0, 0);
2196
+ return rayDir;
2197
+ }
2198
+
2199
+ var m = h / l;
2200
+ var q = cameraGizmoDistance;
2201
+ var x = -q / m;
2202
+ var rayLength = Math.sqrt(Math.pow(q, 2) + Math.pow(x, 2));
2203
+ rayDir.multiplyScalar(rayLength);
2204
+ rayDir.z = 0;
2205
+ return rayDir;
2206
+ }
2207
+ });
2208
+
2209
+ _defineProperty(_assertThisInitialized(_this), "updateMatrixState", function () {
2210
+ //update camera and gizmos state
2211
+ _this._cameraMatrixState.copy(_this.camera.matrix);
2212
+
2213
+ _this._gizmoMatrixState.copy(_this._gizmos.matrix);
2214
+
2215
+ if (_this.camera.isOrthographicCamera) {
2216
+ _this._cameraProjectionState.copy(_this.camera.projectionMatrix);
2217
+
2218
+ _this.camera.updateProjectionMatrix();
2219
+
2220
+ _this._zoomState = _this.camera.zoom;
2221
+ } else if (_this.camera.isPerspectiveCamera) {
2222
+ _this._fovState = _this.camera.fov;
2223
+ }
2224
+ });
2225
+
2226
+ _defineProperty(_assertThisInitialized(_this), "updateTbState", function (newState, updateMatrices) {
2227
+ _this._state = newState;
2228
+
2229
+ if (updateMatrices) {
2230
+ _this.updateMatrixState();
2231
+ }
2232
+ });
2233
+
2234
+ _defineProperty(_assertThisInitialized(_this), "update", function () {
2235
+ var EPS = 0.000001; //check min/max parameters
2236
+
2237
+ if (_this.camera.isOrthographicCamera) {
2238
+ //check zoom
2239
+ if (_this.camera.zoom > _this.maxZoom || _this.camera.zoom < _this.minZoom) {
2240
+ var newZoom = _three.MathUtils.clamp(_this.camera.zoom, _this.minZoom, _this.maxZoom);
2241
+
2242
+ _this.applyTransformMatrix(_this.scale(newZoom / _this.camera.zoom, _this._gizmos.position, true));
2243
+ }
2244
+ } else if (_this.camera.isPerspectiveCamera) {
2245
+ //check distance
2246
+ var distance = _this.camera.position.distanceTo(_this._gizmos.position);
2247
+
2248
+ if (distance > _this.maxDistance + EPS || distance < _this.minDistance - EPS) {
2249
+ var newDistance = _three.MathUtils.clamp(distance, _this.minDistance, _this.maxDistance);
2250
+
2251
+ _this.applyTransformMatrix(_this.scale(newDistance / distance, _this._gizmos.position));
2252
+
2253
+ _this.updateMatrixState();
2254
+ } //check fov
2255
+
2256
+
2257
+ if (_this.camera.fov < _this.minFov || _this.camera.fov > _this.maxFov) {
2258
+ _this.camera.fov = _three.MathUtils.clamp(_this.camera.fov, _this.minFov, _this.maxFov);
2259
+
2260
+ _this.camera.updateProjectionMatrix();
2261
+ }
2262
+
2263
+ var oldRadius = _this._tbRadius;
2264
+ _this._tbRadius = _this.calculateTbRadius(_this.camera);
2265
+
2266
+ if (oldRadius < _this._tbRadius - EPS || oldRadius > _this._tbRadius + EPS) {
2267
+ var scale = (_this._gizmos.scale.x + _this._gizmos.scale.y + _this._gizmos.scale.z) / 3;
2268
+ var newRadius = _this._tbRadius / scale;
2269
+ var curve = new _three.EllipseCurve(0, 0, newRadius, newRadius);
2270
+ var points = curve.getPoints(_this._curvePts);
2271
+ var curveGeometry = new _three.BufferGeometry().setFromPoints(points);
2272
+
2273
+ for (var gizmo in _this._gizmos.children) {
2274
+ _this._gizmos.children[gizmo].geometry = curveGeometry;
2275
+ }
2276
+ }
2277
+ }
2278
+
2279
+ _this.camera.lookAt(_this._gizmos.position);
2280
+ });
2281
+
2282
+ _defineProperty(_assertThisInitialized(_this), "setStateFromJSON", function (json) {
2283
+ var state = JSON.parse(json);
2284
+
2285
+ if (state.arcballState != undefined) {
2286
+ _this._cameraMatrixState.fromArray(state.arcballState.cameraMatrix.elements);
2287
+
2288
+ _this._cameraMatrixState.decompose(_this.camera.position, _this.camera.quaternion, _this.camera.scale);
2289
+
2290
+ _this.camera.up.copy(state.arcballState.cameraUp);
2291
+
2292
+ _this.camera.near = state.arcballState.cameraNear;
2293
+ _this.camera.far = state.arcballState.cameraFar;
2294
+ _this.camera.zoom = state.arcballState.cameraZoom;
2295
+
2296
+ if (_this.camera.isPerspectiveCamera) {
2297
+ _this.camera.fov = state.arcballState.cameraFov;
2298
+ }
2299
+
2300
+ _this._gizmoMatrixState.fromArray(state.arcballState.gizmoMatrix.elements);
2301
+
2302
+ _this._gizmoMatrixState.decompose(_this._gizmos.position, _this._gizmos.quaternion, _this._gizmos.scale);
2303
+
2304
+ _this.camera.updateMatrix();
2305
+
2306
+ _this.camera.updateProjectionMatrix();
2307
+
2308
+ _this._gizmos.updateMatrix();
2309
+
2310
+ _this._tbRadius = _this.calculateTbRadius(_this.camera);
2311
+ var gizmoTmp = new _three.Matrix4().copy(_this._gizmoMatrixState0);
2312
+
2313
+ _this.makeGizmos(_this._gizmos.position, _this._tbRadius);
2314
+
2315
+ _this._gizmoMatrixState0.copy(gizmoTmp);
2316
+
2317
+ _this.camera.lookAt(_this._gizmos.position);
2318
+
2319
+ _this.updateTbState(STATE.IDLE, false);
2320
+
2321
+ _this.dispatchEvent(_changeEvent);
2322
+ }
2323
+ });
2324
+
2325
+ _this.camera = null;
2326
+ _this.domElement = domElement;
2327
+ _this.scene = scene;
2328
+ _this.target = new _three.Vector3(0, 0, 0);
2329
+ _this.radiusFactor = 0.67;
2330
+ _this.mouseActions = [];
2331
+ _this._mouseOp = null; //global vectors and matrices that are used in some operations to avoid creating new objects every time (e.g. every time cursor moves)
2332
+
2333
+ _this._v2_1 = new _three.Vector2();
2334
+ _this._v3_1 = new _three.Vector3();
2335
+ _this._v3_2 = new _three.Vector3();
2336
+ _this._m4_1 = new _three.Matrix4();
2337
+ _this._m4_2 = new _three.Matrix4();
2338
+ _this._quat = new _three.Quaternion(); //transformation matrices
2339
+
2340
+ _this._translationMatrix = new _three.Matrix4(); //matrix for translation operation
2341
+
2342
+ _this._rotationMatrix = new _three.Matrix4(); //matrix for rotation operation
2343
+
2344
+ _this._scaleMatrix = new _three.Matrix4(); //matrix for scaling operation
2345
+
2346
+ _this._rotationAxis = new _three.Vector3(); //axis for rotate operation
2347
+ //camera state
2348
+
2349
+ _this._cameraMatrixState = new _three.Matrix4();
2350
+ _this._cameraProjectionState = new _three.Matrix4();
2351
+ _this._fovState = 1;
2352
+ _this._upState = new _three.Vector3();
2353
+ _this._zoomState = 1;
2354
+ _this._nearPos = 0;
2355
+ _this._farPos = 0;
2356
+ _this._gizmoMatrixState = new _three.Matrix4(); //initial values
2357
+
2358
+ _this._up0 = new _three.Vector3();
2359
+ _this._zoom0 = 1;
2360
+ _this._fov0 = 0;
2361
+ _this._initialNear = 0;
2362
+ _this._nearPos0 = 0;
2363
+ _this._initialFar = 0;
2364
+ _this._farPos0 = 0;
2365
+ _this._cameraMatrixState0 = new _three.Matrix4();
2366
+ _this._gizmoMatrixState0 = new _three.Matrix4(); //pointers array
2367
+
2368
+ _this._button = -1;
2369
+ _this._touchStart = [];
2370
+ _this._touchCurrent = [];
2371
+ _this._input = INPUT.NONE; //two fingers touch interaction
2372
+
2373
+ _this._switchSensibility = 32; //minimum movement to be performed to fire single pan start after the second finger has been released
2374
+
2375
+ _this._startFingerDistance = 0; //distance between two fingers
2376
+
2377
+ _this._currentFingerDistance = 0;
2378
+ _this._startFingerRotation = 0; //amount of rotation performed with two fingers
2379
+
2380
+ _this._currentFingerRotation = 0; //double tap
2381
+
2382
+ _this._devPxRatio = 0;
2383
+ _this._downValid = true;
2384
+ _this._nclicks = 0;
2385
+ _this._downEvents = [];
2386
+ _this._downStart = 0; //pointerDown time
2387
+
2388
+ _this._clickStart = 0; //first click time
2389
+
2390
+ _this._maxDownTime = 250;
2391
+ _this._maxInterval = 300;
2392
+ _this._posThreshold = 24;
2393
+ _this._movementThreshold = 24; //cursor positions
2394
+
2395
+ _this._currentCursorPosition = new _three.Vector3();
2396
+ _this._startCursorPosition = new _three.Vector3(); //grid
2397
+
2398
+ _this._grid = null; //grid to be visualized during pan operation
2399
+
2400
+ _this._gridPosition = new _three.Vector3(); //gizmos
2401
+
2402
+ _this._gizmos = new _three.Group();
2403
+ _this._curvePts = 128; //animations
2404
+
2405
+ _this._timeStart = -1; //initial time
2406
+
2407
+ _this._animationId = -1; //focus animation
2408
+
2409
+ _this.focusAnimationTime = 500; //duration of focus animation in ms
2410
+ //rotate animation
2411
+
2412
+ _this._timePrev = 0; //time at which previous rotate operation has been detected
2413
+
2414
+ _this._timeCurrent = 0; //time at which current rotate operation has been detected
2415
+
2416
+ _this._anglePrev = 0; //angle of previous rotation
2417
+
2418
+ _this._angleCurrent = 0; //angle of current rotation
2419
+
2420
+ _this._cursorPosPrev = new _three.Vector3(); //cursor position when previous rotate operation has been detected
2421
+
2422
+ _this._cursorPosCurr = new _three.Vector3(); //cursor position when current rotate operation has been detected
2423
+
2424
+ _this._wPrev = 0; //angular velocity of the previous rotate operation
2425
+
2426
+ _this._wCurr = 0; //angular velocity of the current rotate operation
2427
+ //parameters
2428
+
2429
+ _this.adjustNearFar = false;
2430
+ _this.scaleFactor = 1.1; //zoom/distance multiplier
2431
+
2432
+ _this.dampingFactor = 25;
2433
+ _this.wMax = 20; //maximum angular velocity allowed
2434
+
2435
+ _this.enableAnimations = true; //if animations should be performed
2436
+
2437
+ _this.enableGrid = false; //if grid should be showed during pan operation
2438
+
2439
+ _this.cursorZoom = false; //if wheel zoom should be cursor centered
2440
+
2441
+ _this.minFov = 5;
2442
+ _this.maxFov = 90;
2443
+ _this.enabled = true;
2444
+ _this.enablePan = true;
2445
+ _this.enableRotate = true;
2446
+ _this.enableZoom = true;
2447
+ _this.enableGizmos = true;
2448
+ _this.minDistance = 0;
2449
+ _this.maxDistance = Infinity;
2450
+ _this.minZoom = 0;
2451
+ _this.maxZoom = Infinity; //trackball parameters
2452
+
2453
+ _this._tbRadius = 1; //FSA
2454
+
2455
+ _this._state = STATE.IDLE;
2456
+
2457
+ _this.setCamera(_camera);
2458
+
2459
+ if (_this.scene != null) {
2460
+ _this.scene.add(_this._gizmos);
2461
+ }
2462
+
2463
+ _this.domElement.style.touchAction = 'none';
2464
+ _this._devPxRatio = window.devicePixelRatio;
2465
+
2466
+ _this.initializeMouseActions();
2467
+
2468
+ _this.domElement.addEventListener('contextmenu', _this.onContextMenu);
2469
+
2470
+ _this.domElement.addEventListener('wheel', _this.onWheel);
2471
+
2472
+ _this.domElement.addEventListener('pointerdown', _this.onPointerDown);
2473
+
2474
+ _this.domElement.addEventListener('pointercancel', _this.onPointerCancel);
2475
+
2476
+ window.addEventListener('keydown', _this.onKeyDown);
2477
+ window.addEventListener('resize', _this.onWindowResize);
2478
+ return _this;
2479
+ } //listeners
2480
+
2481
+
2482
+ _createClass(ArcballControls, [{
2483
+ key: "applyTransformMatrix",
2484
+ value:
2485
+ /**
2486
+ * Apply a transformation matrix, to the camera and gizmos
2487
+ * @param {Object} transformation Object containing matrices to apply to camera and gizmos
2488
+ */
2489
+ function applyTransformMatrix(transformation) {
2490
+ if (transformation.camera != null) {
2491
+ this._m4_1.copy(this._cameraMatrixState).premultiply(transformation.camera);
2492
+
2493
+ this._m4_1.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);
2494
+
2495
+ this.camera.updateMatrix(); //update camera up vector
2496
+
2497
+ if (this._state == STATE.ROTATE || this._state == STATE.ZROTATE || this._state == STATE.ANIMATION_ROTATE) {
2498
+ this.camera.up.copy(this._upState).applyQuaternion(this.camera.quaternion);
2499
+ }
2500
+ }
2501
+
2502
+ if (transformation.gizmos != null) {
2503
+ this._m4_1.copy(this._gizmoMatrixState).premultiply(transformation.gizmos);
2504
+
2505
+ this._m4_1.decompose(this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
2506
+
2507
+ this._gizmos.updateMatrix();
2508
+ }
2509
+
2510
+ if (this._state == STATE.SCALE || this._state == STATE.FOCUS || this._state == STATE.ANIMATION_FOCUS) {
2511
+ this._tbRadius = this.calculateTbRadius(this.camera);
2512
+
2513
+ if (this.adjustNearFar) {
2514
+ var cameraDistance = this.camera.position.distanceTo(this._gizmos.position);
2515
+ var bb = new _three.Box3();
2516
+ bb.setFromObject(this._gizmos);
2517
+ var sphere = new _three.Sphere();
2518
+ bb.getBoundingSphere(sphere);
2519
+ var adjustedNearPosition = Math.max(this._nearPos0, sphere.radius + sphere.center.length());
2520
+ var regularNearPosition = cameraDistance - this._initialNear;
2521
+ var minNearPos = Math.min(adjustedNearPosition, regularNearPosition);
2522
+ this.camera.near = cameraDistance - minNearPos;
2523
+ var adjustedFarPosition = Math.min(this._farPos0, -sphere.radius + sphere.center.length());
2524
+ var regularFarPosition = cameraDistance - this._initialFar;
2525
+ var minFarPos = Math.min(adjustedFarPosition, regularFarPosition);
2526
+ this.camera.far = cameraDistance - minFarPos;
2527
+ this.camera.updateProjectionMatrix();
2528
+ } else {
2529
+ var update = false;
2530
+
2531
+ if (this.camera.near != this._initialNear) {
2532
+ this.camera.near = this._initialNear;
2533
+ update = true;
2534
+ }
2535
+
2536
+ if (this.camera.far != this._initialFar) {
2537
+ this.camera.far = this._initialFar;
2538
+ update = true;
2539
+ }
2540
+
2541
+ if (update) {
2542
+ this.camera.updateProjectionMatrix();
2543
+ }
2544
+ }
2545
+ }
2546
+ }
2547
+ /**
2548
+ * Calculate the angular speed
2549
+ * @param {Number} p0 Position at t0
2550
+ * @param {Number} p1 Position at t1
2551
+ * @param {Number} t0 Initial time in milliseconds
2552
+ * @param {Number} t1 Ending time in milliseconds
2553
+ */
2554
+
2555
+ }, {
2556
+ key: "setGizmosVisible",
2557
+ value:
2558
+ /**
2559
+ * Set gizmos visibility
2560
+ * @param {Boolean} value Value of gizmos visibility
2561
+ */
2562
+ function setGizmosVisible(value) {
2563
+ this._gizmos.visible = value;
2564
+ this.dispatchEvent(_changeEvent);
2565
+ }
2566
+ /**
2567
+ * Set gizmos radius factor and redraws gizmos
2568
+ * @param {Float} value Value of radius factor
2569
+ */
2570
+
2571
+ }, {
2572
+ key: "setTbRadius",
2573
+ value: function setTbRadius(value) {
2574
+ this.radiusFactor = value;
2575
+ this._tbRadius = this.calculateTbRadius(this.camera);
2576
+ var curve = new _three.EllipseCurve(0, 0, this._tbRadius, this._tbRadius);
2577
+ var points = curve.getPoints(this._curvePts);
2578
+ var curveGeometry = new _three.BufferGeometry().setFromPoints(points);
2579
+
2580
+ for (var gizmo in this._gizmos.children) {
2581
+ this._gizmos.children[gizmo].geometry = curveGeometry;
2582
+ }
2583
+
2584
+ this.dispatchEvent(_changeEvent);
2585
+ }
2586
+ /**
2587
+ * Creates the rotation gizmos matching trackball center and radius
2588
+ * @param {Vector3} tbCenter The trackball center
2589
+ * @param {number} tbRadius The trackball radius
2590
+ */
2591
+
2592
+ }, {
2593
+ key: "setTransformationMatrices",
2594
+ value:
2595
+ /**
2596
+ * Set values in transformation object
2597
+ * @param {Matrix4} camera Transformation to be applied to the camera
2598
+ * @param {Matrix4} gizmos Transformation to be applied to gizmos
2599
+ */
2600
+ function setTransformationMatrices() {
2601
+ var camera = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2602
+ var gizmos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2603
+
2604
+ if (camera != null) {
2605
+ if (_transformation.camera != null) {
2606
+ _transformation.camera.copy(camera);
2607
+ } else {
2608
+ _transformation.camera = camera.clone();
2609
+ }
2610
+ } else {
2611
+ _transformation.camera = null;
2612
+ }
2613
+
2614
+ if (gizmos != null) {
2615
+ if (_transformation.gizmos != null) {
2616
+ _transformation.gizmos.copy(gizmos);
2617
+ } else {
2618
+ _transformation.gizmos = gizmos.clone();
2619
+ }
2620
+ } else {
2621
+ _transformation.gizmos = null;
2622
+ }
2623
+ }
2624
+ /**
2625
+ * Rotate camera around its direction axis passing by a given point by a given angle
2626
+ * @param {Vector3} point The point where the rotation axis is passing trough
2627
+ * @param {Number} angle Angle in radians
2628
+ * @returns The computed transormation matix
2629
+ */
2630
+
2631
+ }, {
2632
+ key: "getRaycaster",
2633
+ value: function getRaycaster() {
2634
+ return _raycaster;
2635
+ }
2636
+ /**
2637
+ * Unproject the cursor on the 3D object surface
2638
+ * @param {Vector2} cursor Cursor coordinates in NDC
2639
+ * @param {Camera} camera Virtual camera
2640
+ * @returns {Vector3} The point of intersection with the model, if exist, null otherwise
2641
+ */
2642
+
2643
+ }]);
2644
+
2645
+ return ArcballControls;
2646
+ }(_three.EventDispatcher);
2647
+
2648
+ _exports.ArcballControls = ArcballControls;
2649
+ });