@lampdotdev/lamp 0.0.0-stage → 0.36.2-nightly.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (470) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +397 -2
  3. package/Resources/Devices/roku.json +410 -0
  4. package/Resources/Devices/xbox-one.json +367 -0
  5. package/Resources/GameKit/NOTICE.md +63 -0
  6. package/Resources/GameKit/apple/LampPage.swift +1813 -0
  7. package/Resources/GameKit/apple/LampPlayer.swift +46 -0
  8. package/Resources/GameKit/apple/LampWebApp.swift +63 -0
  9. package/Resources/GameKit/apple/LampWebGame.swift +87 -0
  10. package/Resources/GameKit/apple/Native.swift +12 -0
  11. package/Resources/GameKit/build.sh +55 -0
  12. package/Resources/GameKit/lamp_game.h +116 -0
  13. package/Resources/GameKit/lamp_host.h +19 -0
  14. package/Resources/GameKit/lamp_kit.cpp +61 -0
  15. package/Resources/GameKit/lamp_sound.cpp +455 -0
  16. package/Resources/GameKit/lamp_xbox.cpp +374 -0
  17. package/Resources/GameKit/libraries/HandmadeMath.h +3940 -0
  18. package/Resources/GameKit/libraries/cgltf.h +7240 -0
  19. package/Resources/GameKit/libraries/dr_mp3.h +5430 -0
  20. package/Resources/GameKit/libraries/dr_wav.h +9209 -0
  21. package/Resources/GameKit/libraries/sokol_debugtext.h +4754 -0
  22. package/Resources/GameKit/libraries/sokol_gfx.h +29558 -0
  23. package/Resources/GameKit/libraries/sokol_gl.h +4538 -0
  24. package/Resources/GameKit/libraries/sokol_log.h +335 -0
  25. package/Resources/GameKit/libraries/sokol_shape.h +1531 -0
  26. package/Resources/GameKit/libraries/stb_image.h +7988 -0
  27. package/Resources/GameKit/libraries/stb_vorbis.c +5584 -0
  28. package/Resources/GameKit/page/lamp-live.js +672 -0
  29. package/Resources/GameKit/scaffold/Game/game.cpp +142 -0
  30. package/Resources/GameKit/scaffold/Game/scene.glsl +49 -0
  31. package/Resources/GameKit/scaffold-web/Web/game.js +31 -0
  32. package/Resources/GameKit/scaffold-web/Web/index.html +13 -0
  33. package/Resources/GameKit/scaffold-web/Web/making.js +33 -0
  34. package/Resources/GameKit/scaffold-web/Web/world.js +33 -0
  35. package/Resources/GameKit/web/lamp-game.js +3042 -0
  36. package/Resources/GameKit/web/lamp-phaser.js +128 -0
  37. package/Resources/WebHost/App.exe +0 -0
  38. package/Resources/WebHost/Microsoft.Web.WebView2.Core.dll +0 -0
  39. package/Resources/WebHost/WebView2-LICENSE.txt +27 -0
  40. package/Resources/WebHost/lamp_controllers.h +1506 -0
  41. package/Resources/WebHost/lamp_web_host.cpp +1173 -0
  42. package/Resources/WebLibraries/earlier.txt +318 -0
  43. package/Resources/WebLibraries/phaser/LICENSE.md +20 -0
  44. package/Resources/WebLibraries/phaser/NOTICE.md +2 -0
  45. package/Resources/WebLibraries/phaser/phaser.esm.min.js +1 -0
  46. package/Resources/WebLibraries/qrcode/LICENSE +21 -0
  47. package/Resources/WebLibraries/qrcode/NOTICE.md +4 -0
  48. package/Resources/WebLibraries/qrcode/qrcode.js +2297 -0
  49. package/Resources/WebLibraries/rapier/LICENSE +201 -0
  50. package/Resources/WebLibraries/rapier/NOTICE.md +3 -0
  51. package/Resources/WebLibraries/rapier/rapier.js +2 -0
  52. package/Resources/WebLibraries/three/LICENSE +21 -0
  53. package/Resources/WebLibraries/three/NOTICE.md +4 -0
  54. package/Resources/WebLibraries/three/addons/animation/AnimationClipCreator.js +168 -0
  55. package/Resources/WebLibraries/three/addons/animation/CCDIKSolver.js +607 -0
  56. package/Resources/WebLibraries/three/addons/controls/ArcballControls.js +3543 -0
  57. package/Resources/WebLibraries/three/addons/controls/DragControls.js +452 -0
  58. package/Resources/WebLibraries/three/addons/controls/FirstPersonControls.js +512 -0
  59. package/Resources/WebLibraries/three/addons/controls/FlyControls.js +384 -0
  60. package/Resources/WebLibraries/three/addons/controls/MapControls.js +116 -0
  61. package/Resources/WebLibraries/three/addons/controls/OrbitControls.js +1985 -0
  62. package/Resources/WebLibraries/three/addons/controls/PointerLockControls.js +264 -0
  63. package/Resources/WebLibraries/three/addons/controls/TrackballControls.js +1106 -0
  64. package/Resources/WebLibraries/three/addons/controls/TransformControls.js +2003 -0
  65. package/Resources/WebLibraries/three/addons/curves/CurveExtras.js +694 -0
  66. package/Resources/WebLibraries/three/addons/curves/NURBSCurve.js +169 -0
  67. package/Resources/WebLibraries/three/addons/curves/NURBSSurface.js +98 -0
  68. package/Resources/WebLibraries/three/addons/curves/NURBSUtils.js +532 -0
  69. package/Resources/WebLibraries/three/addons/curves/NURBSVolume.js +82 -0
  70. package/Resources/WebLibraries/three/addons/effects/AnaglyphEffect.js +274 -0
  71. package/Resources/WebLibraries/three/addons/effects/AsciiEffect.js +323 -0
  72. package/Resources/WebLibraries/three/addons/effects/OutlineEffect.js +489 -0
  73. package/Resources/WebLibraries/three/addons/effects/ParallaxBarrierEffect.js +155 -0
  74. package/Resources/WebLibraries/three/addons/effects/StereoEffect.js +91 -0
  75. package/Resources/WebLibraries/three/addons/environments/ColorEnvironment.js +59 -0
  76. package/Resources/WebLibraries/three/addons/environments/DebugEnvironment.js +102 -0
  77. package/Resources/WebLibraries/three/addons/environments/RoomEnvironment.js +185 -0
  78. package/Resources/WebLibraries/three/addons/geometries/BoxLineGeometry.js +92 -0
  79. package/Resources/WebLibraries/three/addons/geometries/ConvexGeometry.js +72 -0
  80. package/Resources/WebLibraries/three/addons/geometries/DecalGeometry.js +420 -0
  81. package/Resources/WebLibraries/three/addons/geometries/LoftGeometry.js +355 -0
  82. package/Resources/WebLibraries/three/addons/geometries/ParametricFunctions.js +100 -0
  83. package/Resources/WebLibraries/three/addons/geometries/ParametricGeometry.js +172 -0
  84. package/Resources/WebLibraries/three/addons/geometries/RoundedBoxGeometry.js +216 -0
  85. package/Resources/WebLibraries/three/addons/geometries/TeapotGeometry.js +689 -0
  86. package/Resources/WebLibraries/three/addons/geometries/TextGeometry.js +102 -0
  87. package/Resources/WebLibraries/three/addons/helpers/AnimationPathHelper.js +302 -0
  88. package/Resources/WebLibraries/three/addons/helpers/LightProbeGridHelper.js +166 -0
  89. package/Resources/WebLibraries/three/addons/helpers/LightProbeGridHelperWebGL.js +221 -0
  90. package/Resources/WebLibraries/three/addons/helpers/LightProbeHelper.js +166 -0
  91. package/Resources/WebLibraries/three/addons/helpers/LightProbeHelperGPU.js +102 -0
  92. package/Resources/WebLibraries/three/addons/helpers/OctreeHelper.js +109 -0
  93. package/Resources/WebLibraries/three/addons/helpers/PositionalAudioHelper.js +169 -0
  94. package/Resources/WebLibraries/three/addons/helpers/RapierHelper.js +59 -0
  95. package/Resources/WebLibraries/three/addons/helpers/RectAreaLightHelper.js +118 -0
  96. package/Resources/WebLibraries/three/addons/helpers/TextureHelper.js +265 -0
  97. package/Resources/WebLibraries/three/addons/helpers/TextureHelperGPU.js +214 -0
  98. package/Resources/WebLibraries/three/addons/helpers/VertexNormalsHelper.js +155 -0
  99. package/Resources/WebLibraries/three/addons/helpers/VertexTangentsHelper.js +133 -0
  100. package/Resources/WebLibraries/three/addons/helpers/ViewHelper.js +529 -0
  101. package/Resources/WebLibraries/three/addons/interactive/HTMLMesh.js +617 -0
  102. package/Resources/WebLibraries/three/addons/interactive/InteractiveGroup.js +224 -0
  103. package/Resources/WebLibraries/three/addons/interactive/SelectionBox.js +324 -0
  104. package/Resources/WebLibraries/three/addons/interactive/SelectionHelper.js +150 -0
  105. package/Resources/WebLibraries/three/addons/libs/fflate.module.js +2699 -0
  106. package/Resources/WebLibraries/three/addons/libs/lil-gui.module.min.js +8 -0
  107. package/Resources/WebLibraries/three/addons/libs/meshopt_decoder.module.js +196 -0
  108. package/Resources/WebLibraries/three/addons/libs/potpack.module.js +125 -0
  109. package/Resources/WebLibraries/three/addons/libs/stats.module.js +167 -0
  110. package/Resources/WebLibraries/three/addons/libs/tween.module.js +876 -0
  111. package/Resources/WebLibraries/three/addons/lighting/ClusteredLighting.js +153 -0
  112. package/Resources/WebLibraries/three/addons/lighting/DynamicLighting.js +82 -0
  113. package/Resources/WebLibraries/three/addons/lighting/LightMapper.js +295 -0
  114. package/Resources/WebLibraries/three/addons/lighting/LightProbeGrid.js +923 -0
  115. package/Resources/WebLibraries/three/addons/lighting/LightProbeGridUtils.js +107 -0
  116. package/Resources/WebLibraries/three/addons/lighting/LightProbeGridWebGL.js +846 -0
  117. package/Resources/WebLibraries/three/addons/lighting/vxgi/VXGIConeTracer.js +243 -0
  118. package/Resources/WebLibraries/three/addons/lighting/vxgi/VXGIIrradiance.js +43 -0
  119. package/Resources/WebLibraries/three/addons/lighting/vxgi/VXGINode.js +617 -0
  120. package/Resources/WebLibraries/three/addons/lighting/vxgi/VXGISceneCollector.js +793 -0
  121. package/Resources/WebLibraries/three/addons/lighting/vxgi/VXGIVolume.js +1440 -0
  122. package/Resources/WebLibraries/three/addons/lights/LightProbeGenerator.js +337 -0
  123. package/Resources/WebLibraries/three/addons/lights/RectAreaLightTexturesLib.js +127 -0
  124. package/Resources/WebLibraries/three/addons/lights/RectAreaLightUniformsLib.js +40 -0
  125. package/Resources/WebLibraries/three/addons/lights/SunLight.js +100 -0
  126. package/Resources/WebLibraries/three/addons/lights/SunLightNode.js +56 -0
  127. package/Resources/WebLibraries/three/addons/lights/SunLightShadow.js +319 -0
  128. package/Resources/WebLibraries/three/addons/lights/SunShadowNode.js +312 -0
  129. package/Resources/WebLibraries/three/addons/lines/Line2.js +56 -0
  130. package/Resources/WebLibraries/three/addons/lines/LineGeometry.js +157 -0
  131. package/Resources/WebLibraries/three/addons/lines/LineMaterial.js +742 -0
  132. package/Resources/WebLibraries/three/addons/lines/LineSegments2.js +434 -0
  133. package/Resources/WebLibraries/three/addons/lines/LineSegmentsGeometry.js +298 -0
  134. package/Resources/WebLibraries/three/addons/lines/Wireframe.js +108 -0
  135. package/Resources/WebLibraries/three/addons/lines/WireframeGeometry2.js +49 -0
  136. package/Resources/WebLibraries/three/addons/lines/webgpu/Line2.js +46 -0
  137. package/Resources/WebLibraries/three/addons/lines/webgpu/LineSegments2.js +419 -0
  138. package/Resources/WebLibraries/three/addons/lines/webgpu/Wireframe.js +86 -0
  139. package/Resources/WebLibraries/three/addons/loaders/EXRLoader.js +3411 -0
  140. package/Resources/WebLibraries/three/addons/loaders/FBXLoader.js +4660 -0
  141. package/Resources/WebLibraries/three/addons/loaders/FontLoader.js +262 -0
  142. package/Resources/WebLibraries/three/addons/loaders/GLTFLoader.js +5006 -0
  143. package/Resources/WebLibraries/three/addons/loaders/HDRLoader.js +463 -0
  144. package/Resources/WebLibraries/three/addons/loaders/MTLLoader.js +601 -0
  145. package/Resources/WebLibraries/three/addons/loaders/OBJLoader.js +961 -0
  146. package/Resources/WebLibraries/three/addons/loaders/PLYLoader.js +992 -0
  147. package/Resources/WebLibraries/three/addons/loaders/RGBELoader.js +18 -0
  148. package/Resources/WebLibraries/three/addons/loaders/STLLoader.js +423 -0
  149. package/Resources/WebLibraries/three/addons/loaders/SVGLoader.js +3297 -0
  150. package/Resources/WebLibraries/three/addons/loaders/TGALoader.js +539 -0
  151. package/Resources/WebLibraries/three/addons/loaders/UltraHDRLoader.js +757 -0
  152. package/Resources/WebLibraries/three/addons/math/Capsule.js +159 -0
  153. package/Resources/WebLibraries/three/addons/math/ColorConverter.js +62 -0
  154. package/Resources/WebLibraries/three/addons/math/ColorSpaces.js +147 -0
  155. package/Resources/WebLibraries/three/addons/math/ConvexHull.js +1695 -0
  156. package/Resources/WebLibraries/three/addons/math/ImprovedNoise.js +88 -0
  157. package/Resources/WebLibraries/three/addons/math/Lut.js +317 -0
  158. package/Resources/WebLibraries/three/addons/math/MeshSurfaceSampler.js +315 -0
  159. package/Resources/WebLibraries/three/addons/math/OBB.js +535 -0
  160. package/Resources/WebLibraries/three/addons/math/Octree.js +825 -0
  161. package/Resources/WebLibraries/three/addons/math/SimplexNoise.js +470 -0
  162. package/Resources/WebLibraries/three/addons/misc/ConvexObjectBreaker.js +539 -0
  163. package/Resources/WebLibraries/three/addons/misc/GPUComputationRenderer.js +508 -0
  164. package/Resources/WebLibraries/three/addons/misc/Gyroscope.js +78 -0
  165. package/Resources/WebLibraries/three/addons/misc/MorphAnimMesh.js +119 -0
  166. package/Resources/WebLibraries/three/addons/misc/MorphBlendMesh.js +425 -0
  167. package/Resources/WebLibraries/three/addons/misc/ProgressiveLightMap.js +370 -0
  168. package/Resources/WebLibraries/three/addons/misc/ProgressiveLightMapGPU.js +322 -0
  169. package/Resources/WebLibraries/three/addons/misc/RollerCoaster.js +661 -0
  170. package/Resources/WebLibraries/three/addons/misc/Sculptor.js +1679 -0
  171. package/Resources/WebLibraries/three/addons/misc/SculptorMesh.js +1504 -0
  172. package/Resources/WebLibraries/three/addons/misc/SculptorTools.js +1180 -0
  173. package/Resources/WebLibraries/three/addons/misc/SculptorUtils.js +345 -0
  174. package/Resources/WebLibraries/three/addons/misc/TileCreasedNormalsPlugin.js +270 -0
  175. package/Resources/WebLibraries/three/addons/misc/TubePainter.js +611 -0
  176. package/Resources/WebLibraries/three/addons/misc/Volume.js +520 -0
  177. package/Resources/WebLibraries/three/addons/misc/VolumeSlice.js +275 -0
  178. package/Resources/WebLibraries/three/addons/modifiers/CurveModifier.js +374 -0
  179. package/Resources/WebLibraries/three/addons/modifiers/CurveModifierGPU.js +256 -0
  180. package/Resources/WebLibraries/three/addons/modifiers/EdgeSplitModifier.js +299 -0
  181. package/Resources/WebLibraries/three/addons/modifiers/TessellateModifier.js +340 -0
  182. package/Resources/WebLibraries/three/addons/objects/GroundedSkybox.js +69 -0
  183. package/Resources/WebLibraries/three/addons/objects/Lensflare.js +489 -0
  184. package/Resources/WebLibraries/three/addons/objects/LensflareMesh.js +376 -0
  185. package/Resources/WebLibraries/three/addons/objects/MarchingCubes.js +1261 -0
  186. package/Resources/WebLibraries/three/addons/objects/Reflector.js +390 -0
  187. package/Resources/WebLibraries/three/addons/objects/ReflectorForSSRPass.js +393 -0
  188. package/Resources/WebLibraries/three/addons/objects/Refractor.js +389 -0
  189. package/Resources/WebLibraries/three/addons/objects/ShadowMesh.js +130 -0
  190. package/Resources/WebLibraries/three/addons/objects/Sky.js +342 -0
  191. package/Resources/WebLibraries/three/addons/objects/SkyMesh.js +403 -0
  192. package/Resources/WebLibraries/three/addons/objects/Water.js +374 -0
  193. package/Resources/WebLibraries/three/addons/objects/Water2.js +403 -0
  194. package/Resources/WebLibraries/three/addons/objects/Water2Mesh.js +199 -0
  195. package/Resources/WebLibraries/three/addons/objects/WaterMesh.js +194 -0
  196. package/Resources/WebLibraries/three/addons/postprocessing/AfterimagePass.js +187 -0
  197. package/Resources/WebLibraries/three/addons/postprocessing/BloomPass.js +274 -0
  198. package/Resources/WebLibraries/three/addons/postprocessing/BokehPass.js +218 -0
  199. package/Resources/WebLibraries/three/addons/postprocessing/ClearPass.js +97 -0
  200. package/Resources/WebLibraries/three/addons/postprocessing/CubeTexturePass.js +146 -0
  201. package/Resources/WebLibraries/three/addons/postprocessing/DotScreenPass.js +114 -0
  202. package/Resources/WebLibraries/three/addons/postprocessing/EffectComposer.js +365 -0
  203. package/Resources/WebLibraries/three/addons/postprocessing/FXAAPass.js +40 -0
  204. package/Resources/WebLibraries/three/addons/postprocessing/FilmPass.js +113 -0
  205. package/Resources/WebLibraries/three/addons/postprocessing/GTAOPass.js +735 -0
  206. package/Resources/WebLibraries/three/addons/postprocessing/GlitchPass.js +177 -0
  207. package/Resources/WebLibraries/three/addons/postprocessing/HalftonePass.js +134 -0
  208. package/Resources/WebLibraries/three/addons/postprocessing/LUTPass.js +138 -0
  209. package/Resources/WebLibraries/three/addons/postprocessing/MaskPass.js +195 -0
  210. package/Resources/WebLibraries/three/addons/postprocessing/OutlinePass.js +776 -0
  211. package/Resources/WebLibraries/three/addons/postprocessing/OutputPass.js +148 -0
  212. package/Resources/WebLibraries/three/addons/postprocessing/Pass.js +191 -0
  213. package/Resources/WebLibraries/three/addons/postprocessing/RenderPass.js +193 -0
  214. package/Resources/WebLibraries/three/addons/postprocessing/RenderPixelatedPass.js +314 -0
  215. package/Resources/WebLibraries/three/addons/postprocessing/RenderTransitionPass.js +267 -0
  216. package/Resources/WebLibraries/three/addons/postprocessing/SAOPass.js +407 -0
  217. package/Resources/WebLibraries/three/addons/postprocessing/SMAAPass.js +230 -0
  218. package/Resources/WebLibraries/three/addons/postprocessing/SSAARenderPass.js +313 -0
  219. package/Resources/WebLibraries/three/addons/postprocessing/SSAOPass.js +527 -0
  220. package/Resources/WebLibraries/three/addons/postprocessing/SSRPass.js +858 -0
  221. package/Resources/WebLibraries/three/addons/postprocessing/SavePass.js +132 -0
  222. package/Resources/WebLibraries/three/addons/postprocessing/ShaderPass.js +135 -0
  223. package/Resources/WebLibraries/three/addons/postprocessing/TAARenderPass.js +243 -0
  224. package/Resources/WebLibraries/three/addons/postprocessing/TexturePass.js +131 -0
  225. package/Resources/WebLibraries/three/addons/postprocessing/UnrealBloomPass.js +541 -0
  226. package/Resources/WebLibraries/three/addons/shaders/ACESFilmicToneMappingShader.js +96 -0
  227. package/Resources/WebLibraries/three/addons/shaders/AfterimageShader.js +63 -0
  228. package/Resources/WebLibraries/three/addons/shaders/BasicShader.js +36 -0
  229. package/Resources/WebLibraries/three/addons/shaders/BleachBypassShader.js +68 -0
  230. package/Resources/WebLibraries/three/addons/shaders/BlendShader.js +56 -0
  231. package/Resources/WebLibraries/three/addons/shaders/BokehShader.js +151 -0
  232. package/Resources/WebLibraries/three/addons/shaders/BokehShader2.js +404 -0
  233. package/Resources/WebLibraries/three/addons/shaders/BrightnessContrastShader.js +62 -0
  234. package/Resources/WebLibraries/three/addons/shaders/ColorCorrectionShader.js +59 -0
  235. package/Resources/WebLibraries/three/addons/shaders/ColorifyShader.js +57 -0
  236. package/Resources/WebLibraries/three/addons/shaders/ConvolutionShader.js +74 -0
  237. package/Resources/WebLibraries/three/addons/shaders/CopyShader.js +52 -0
  238. package/Resources/WebLibraries/three/addons/shaders/DOFMipMapShader.js +63 -0
  239. package/Resources/WebLibraries/three/addons/shaders/DepthLimitedBlurShader.js +183 -0
  240. package/Resources/WebLibraries/three/addons/shaders/DigitalGlitch.js +104 -0
  241. package/Resources/WebLibraries/three/addons/shaders/DotScreenShader.js +75 -0
  242. package/Resources/WebLibraries/three/addons/shaders/ExposureShader.js +51 -0
  243. package/Resources/WebLibraries/three/addons/shaders/FXAAShader.js +298 -0
  244. package/Resources/WebLibraries/three/addons/shaders/FilmShader.js +73 -0
  245. package/Resources/WebLibraries/three/addons/shaders/FocusShader.js +94 -0
  246. package/Resources/WebLibraries/three/addons/shaders/FreiChenShader.js +103 -0
  247. package/Resources/WebLibraries/three/addons/shaders/GTAOShader.js +437 -0
  248. package/Resources/WebLibraries/three/addons/shaders/GammaCorrectionShader.js +52 -0
  249. package/Resources/WebLibraries/three/addons/shaders/HalftoneShader.js +332 -0
  250. package/Resources/WebLibraries/three/addons/shaders/HorizontalBlurShader.js +68 -0
  251. package/Resources/WebLibraries/three/addons/shaders/HorizontalTiltShiftShader.js +70 -0
  252. package/Resources/WebLibraries/three/addons/shaders/HueSaturationShader.js +74 -0
  253. package/Resources/WebLibraries/three/addons/shaders/KaleidoShader.js +65 -0
  254. package/Resources/WebLibraries/three/addons/shaders/LuminosityHighPassShader.js +68 -0
  255. package/Resources/WebLibraries/three/addons/shaders/LuminosityShader.js +54 -0
  256. package/Resources/WebLibraries/three/addons/shaders/MirrorShader.js +62 -0
  257. package/Resources/WebLibraries/three/addons/shaders/NormalMapShader.js +60 -0
  258. package/Resources/WebLibraries/three/addons/shaders/OutputShader.js +103 -0
  259. package/Resources/WebLibraries/three/addons/shaders/PoissonDenoiseShader.js +230 -0
  260. package/Resources/WebLibraries/three/addons/shaders/RGBShiftShader.js +61 -0
  261. package/Resources/WebLibraries/three/addons/shaders/SAOShader.js +201 -0
  262. package/Resources/WebLibraries/three/addons/shaders/SMAAShader.js +489 -0
  263. package/Resources/WebLibraries/three/addons/shaders/SSAOShader.js +331 -0
  264. package/Resources/WebLibraries/three/addons/shaders/SSRShader.js +396 -0
  265. package/Resources/WebLibraries/three/addons/shaders/SepiaShader.js +57 -0
  266. package/Resources/WebLibraries/three/addons/shaders/SobelOperatorShader.js +98 -0
  267. package/Resources/WebLibraries/three/addons/shaders/SubsurfaceScatteringShader.js +95 -0
  268. package/Resources/WebLibraries/three/addons/shaders/TechnicolorShader.js +51 -0
  269. package/Resources/WebLibraries/three/addons/shaders/ToonShader.js +349 -0
  270. package/Resources/WebLibraries/three/addons/shaders/TriangleBlurShader.js +79 -0
  271. package/Resources/WebLibraries/three/addons/shaders/UnpackDepthRGBAShader.js +60 -0
  272. package/Resources/WebLibraries/three/addons/shaders/VelocityShader.js +137 -0
  273. package/Resources/WebLibraries/three/addons/shaders/VerticalBlurShader.js +66 -0
  274. package/Resources/WebLibraries/three/addons/shaders/VerticalTiltShiftShader.js +70 -0
  275. package/Resources/WebLibraries/three/addons/shaders/VignetteShader.js +56 -0
  276. package/Resources/WebLibraries/three/addons/shaders/VolumeShader.js +285 -0
  277. package/Resources/WebLibraries/three/addons/shaders/WaterRefractionShader.js +106 -0
  278. package/Resources/WebLibraries/three/addons/textures/FlakesTexture.js +54 -0
  279. package/Resources/WebLibraries/three/addons/tsl/WebGLNodesHandler.js +607 -0
  280. package/Resources/WebLibraries/three/addons/tsl/display/AfterImageNode.js +256 -0
  281. package/Resources/WebLibraries/three/addons/tsl/display/AnaglyphPassNode.js +550 -0
  282. package/Resources/WebLibraries/three/addons/tsl/display/BilateralBlurNode.js +377 -0
  283. package/Resources/WebLibraries/three/addons/tsl/display/BleachBypass.js +33 -0
  284. package/Resources/WebLibraries/three/addons/tsl/display/BloomNode.js +599 -0
  285. package/Resources/WebLibraries/three/addons/tsl/display/CRT.js +150 -0
  286. package/Resources/WebLibraries/three/addons/tsl/display/ChromaticAberrationNode.js +163 -0
  287. package/Resources/WebLibraries/three/addons/tsl/display/DenoiseNode.js +354 -0
  288. package/Resources/WebLibraries/three/addons/tsl/display/DepthOfFieldNode.js +572 -0
  289. package/Resources/WebLibraries/three/addons/tsl/display/DotScreenNode.js +104 -0
  290. package/Resources/WebLibraries/three/addons/tsl/display/FSR1Node.js +481 -0
  291. package/Resources/WebLibraries/three/addons/tsl/display/FXAANode.js +357 -0
  292. package/Resources/WebLibraries/three/addons/tsl/display/FilmNode.js +101 -0
  293. package/Resources/WebLibraries/three/addons/tsl/display/GTAONode.js +727 -0
  294. package/Resources/WebLibraries/three/addons/tsl/display/GaussianBlurNode.js +412 -0
  295. package/Resources/WebLibraries/three/addons/tsl/display/GodraysNode.js +604 -0
  296. package/Resources/WebLibraries/three/addons/tsl/display/ImportanceSampledEnvironment.js +564 -0
  297. package/Resources/WebLibraries/three/addons/tsl/display/LensflareNode.js +282 -0
  298. package/Resources/WebLibraries/three/addons/tsl/display/Lut3DNode.js +109 -0
  299. package/Resources/WebLibraries/three/addons/tsl/display/MotionBlur.js +33 -0
  300. package/Resources/WebLibraries/three/addons/tsl/display/OITPassNode.js +341 -0
  301. package/Resources/WebLibraries/three/addons/tsl/display/OutlineNode.js +916 -0
  302. package/Resources/WebLibraries/three/addons/tsl/display/ParallaxBarrierPassNode.js +90 -0
  303. package/Resources/WebLibraries/three/addons/tsl/display/PixelationPassNode.js +227 -0
  304. package/Resources/WebLibraries/three/addons/tsl/display/RGBShiftNode.js +96 -0
  305. package/Resources/WebLibraries/three/addons/tsl/display/RecurrentDenoiseNode.js +812 -0
  306. package/Resources/WebLibraries/three/addons/tsl/display/RetroPassNode.js +263 -0
  307. package/Resources/WebLibraries/three/addons/tsl/display/SMAANode.js +729 -0
  308. package/Resources/WebLibraries/three/addons/tsl/display/SSAAPassNode.js +344 -0
  309. package/Resources/WebLibraries/three/addons/tsl/display/SSAONode.js +422 -0
  310. package/Resources/WebLibraries/three/addons/tsl/display/SSGINode.js +698 -0
  311. package/Resources/WebLibraries/three/addons/tsl/display/SSRNode.js +1430 -0
  312. package/Resources/WebLibraries/three/addons/tsl/display/SSSNode.js +479 -0
  313. package/Resources/WebLibraries/three/addons/tsl/display/Sepia.js +24 -0
  314. package/Resources/WebLibraries/three/addons/tsl/display/Shape.js +29 -0
  315. package/Resources/WebLibraries/three/addons/tsl/display/SharpenNode.js +284 -0
  316. package/Resources/WebLibraries/three/addons/tsl/display/SobelOperatorNode.js +168 -0
  317. package/Resources/WebLibraries/three/addons/tsl/display/StereoCompositePassNode.js +190 -0
  318. package/Resources/WebLibraries/three/addons/tsl/display/StereoPassNode.js +117 -0
  319. package/Resources/WebLibraries/three/addons/tsl/display/TAAUNode.js +700 -0
  320. package/Resources/WebLibraries/three/addons/tsl/display/TRAANode.js +609 -0
  321. package/Resources/WebLibraries/three/addons/tsl/display/TemporalReprojectNode.js +1024 -0
  322. package/Resources/WebLibraries/three/addons/tsl/display/TransitionNode.js +141 -0
  323. package/Resources/WebLibraries/three/addons/tsl/display/boxBlur.js +65 -0
  324. package/Resources/WebLibraries/three/addons/tsl/display/depthAwareBlend.js +80 -0
  325. package/Resources/WebLibraries/three/addons/tsl/display/depthAwareBlur.js +63 -0
  326. package/Resources/WebLibraries/three/addons/tsl/display/hashBlur.js +55 -0
  327. package/Resources/WebLibraries/three/addons/tsl/display/lensDirt.js +30 -0
  328. package/Resources/WebLibraries/three/addons/tsl/display/radialBlur.js +68 -0
  329. package/Resources/WebLibraries/three/addons/tsl/lighting/ClusteredLightsNode.js +994 -0
  330. package/Resources/WebLibraries/three/addons/tsl/lighting/DynamicLightsNode.js +201 -0
  331. package/Resources/WebLibraries/three/addons/tsl/lighting/LightProbeGridNode.js +183 -0
  332. package/Resources/WebLibraries/three/addons/tsl/lighting/data/AmbientLightDataNode.js +67 -0
  333. package/Resources/WebLibraries/three/addons/tsl/lighting/data/DirectionalLightDataNode.js +117 -0
  334. package/Resources/WebLibraries/three/addons/tsl/lighting/data/HemisphereLightDataNode.js +105 -0
  335. package/Resources/WebLibraries/three/addons/tsl/lighting/data/PointLightDataNode.js +140 -0
  336. package/Resources/WebLibraries/three/addons/tsl/lighting/data/SpotLightDataNode.js +167 -0
  337. package/Resources/WebLibraries/three/addons/tsl/math/Bayer.js +84 -0
  338. package/Resources/WebLibraries/three/addons/tsl/math/curlNoise.js +107 -0
  339. package/Resources/WebLibraries/three/addons/tsl/math/voronoiNoise.js +112 -0
  340. package/Resources/WebLibraries/three/addons/tsl/shadows/TileShadowNode.js +542 -0
  341. package/Resources/WebLibraries/three/addons/tsl/shadows/TileShadowNodeHelper.js +212 -0
  342. package/Resources/WebLibraries/three/addons/tsl/utils/GroundedSkybox.js +62 -0
  343. package/Resources/WebLibraries/three/addons/tsl/utils/RNoise.js +51 -0
  344. package/Resources/WebLibraries/three/addons/tsl/utils/Raymarching.js +70 -0
  345. package/Resources/WebLibraries/three/addons/tsl/utils/SoftParticles.js +53 -0
  346. package/Resources/WebLibraries/three/addons/tsl/utils/SpecularHelpers.js +302 -0
  347. package/Resources/WebLibraries/three/addons/tsl/utils/TAAUtils.js +184 -0
  348. package/Resources/WebLibraries/three/addons/utils/BufferGeometryUtils.js +1523 -0
  349. package/Resources/WebLibraries/three/addons/utils/CameraUtils.js +82 -0
  350. package/Resources/WebLibraries/three/addons/utils/ColorUtils.js +76 -0
  351. package/Resources/WebLibraries/three/addons/utils/GaussianSplatUtils.js +229 -0
  352. package/Resources/WebLibraries/three/addons/utils/GeometryCompressionUtils.js +547 -0
  353. package/Resources/WebLibraries/three/addons/utils/GeometryUtils.js +226 -0
  354. package/Resources/WebLibraries/three/addons/utils/LDrawUtils.js +211 -0
  355. package/Resources/WebLibraries/three/addons/utils/SceneOptimizer.js +459 -0
  356. package/Resources/WebLibraries/three/addons/utils/SceneUtils.js +363 -0
  357. package/Resources/WebLibraries/three/addons/utils/ShadowMapViewer.js +244 -0
  358. package/Resources/WebLibraries/three/addons/utils/ShadowMapViewerGPU.js +233 -0
  359. package/Resources/WebLibraries/three/addons/utils/SkeletonUtils.js +496 -0
  360. package/Resources/WebLibraries/three/addons/utils/SortUtils.js +175 -0
  361. package/Resources/WebLibraries/three/addons/utils/UVsDebug.js +173 -0
  362. package/Resources/WebLibraries/three/addons/utils/WebGLTextureUtils.js +115 -0
  363. package/Resources/WebLibraries/three/addons/utils/WebGPUTextureUtils.js +81 -0
  364. package/Resources/WebLibraries/three/addons/utils/WorkerPool.js +167 -0
  365. package/Resources/WebLibraries/three/addons/utils/unwrapUVs.js +865 -0
  366. package/Resources/WebLibraries/three/three.core.js +61162 -0
  367. package/Resources/WebLibraries/three/three.module.js +19537 -0
  368. package/Resources/WebLibraries/three/three.tsl.js +41903 -0
  369. package/Resources/WebLibraries/three/three.webgpu.js +53714 -0
  370. package/Resources/share-rules.json +64 -0
  371. package/Resources/skills/2d-game/SKILL.md +305 -0
  372. package/Resources/skills/3d-game/SKILL.md +274 -0
  373. package/Resources/skills/accounts/SKILL.md +41 -0
  374. package/Resources/skills/android-design/SKILL.md +159 -0
  375. package/Resources/skills/app-ai/SKILL.md +154 -0
  376. package/Resources/skills/app-intents/SKILL.md +31 -0
  377. package/Resources/skills/app-kinds/SKILL.md +122 -0
  378. package/Resources/skills/apple-watch/SKILL.md +43 -0
  379. package/Resources/skills/assets/SKILL.md +183 -0
  380. package/Resources/skills/building-blocks/SKILL.md +97 -0
  381. package/Resources/skills/device-control/SKILL.md +56 -0
  382. package/Resources/skills/device-integrations/SKILL.md +278 -0
  383. package/Resources/skills/finder-files/SKILL.md +19 -0
  384. package/Resources/skills/game/SKILL.md +416 -0
  385. package/Resources/skills/game-3d/SKILL.md +12 -0
  386. package/Resources/skills/game-art/SKILL.md +11 -0
  387. package/Resources/skills/game-feel/SKILL.md +13 -0
  388. package/Resources/skills/game-levels/SKILL.md +12 -0
  389. package/Resources/skills/game-live/SKILL.md +12 -0
  390. package/Resources/skills/game-physics/SKILL.md +13 -0
  391. package/Resources/skills/game-playtest/SKILL.md +26 -0
  392. package/Resources/skills/game-ui/SKILL.md +278 -0
  393. package/Resources/skills/github-projects/SKILL.md +62 -0
  394. package/Resources/skills/icloud-sync/SKILL.md +30 -0
  395. package/Resources/skills/iphone-hardware/SKILL.md +57 -0
  396. package/Resources/skills/iphone-widgets/SKILL.md +53 -0
  397. package/Resources/skills/lg-developer-mode/SKILL.md +152 -0
  398. package/Resources/skills/mac-widgets/SKILL.md +60 -0
  399. package/Resources/skills/maps/SKILL.md +8 -0
  400. package/Resources/skills/menu-bar/SKILL.md +36 -0
  401. package/Resources/skills/more-apps/SKILL.md +53 -0
  402. package/Resources/skills/phone-controllers/SKILL.md +79 -0
  403. package/Resources/skills/phone-pages/SKILL.md +173 -0
  404. package/Resources/skills/roku-developer-mode/SKILL.md +106 -0
  405. package/Resources/skills/scene-3d/SKILL.md +27 -0
  406. package/Resources/skills/scripting/SKILL.md +17 -0
  407. package/Resources/skills/share-extension/SKILL.md +22 -0
  408. package/Resources/skills/tv-design/SKILL.md +72 -0
  409. package/Resources/skills/web-app/SKILL.md +170 -0
  410. package/Resources/skills/web-game/SKILL.md +95 -0
  411. package/Resources/skills/web-or-native/SKILL.md +108 -0
  412. package/Resources/skills/wish-links/SKILL.md +156 -0
  413. package/THIRD_PARTY_NOTICES.md +170 -0
  414. package/cli/ai.mjs +237 -0
  415. package/cli/android.mjs +941 -0
  416. package/cli/app-ai.mjs +473 -0
  417. package/cli/browser.mjs +284 -0
  418. package/cli/calls.mjs +594 -0
  419. package/cli/dev.mjs +820 -0
  420. package/cli/devices.mjs +984 -0
  421. package/cli/lamp.mjs +1326 -0
  422. package/cli/lampapp.mjs +332 -0
  423. package/cli/lamps/android-host/LampPageGateway.kt +345 -0
  424. package/cli/lamps/android-host/app/build.gradle.kts +40 -0
  425. package/cli/lamps/android-host/build.gradle.kts +4 -0
  426. package/cli/lamps/android-host/game/AndroidManifest.xml +33 -0
  427. package/cli/lamps/android-host/game/MainActivity.kt +173 -0
  428. package/cli/lamps/android-host/gradle/libs.versions.toml +39 -0
  429. package/cli/lamps/android-host/gradle.properties +8 -0
  430. package/cli/lamps/android-host/page/AndroidManifest.xml +35 -0
  431. package/cli/lamps/android-host/page/MainActivity.kt +193 -0
  432. package/cli/lamps/android-host/settings.gradle.kts +30 -0
  433. package/cli/lamps/android-host/tools.json +43 -0
  434. package/cli/lamps/lamp-controllers.js +2 -0
  435. package/cli/lamps/lamp-for-games.js +6922 -0
  436. package/cli/lamps/lamp.js +7082 -0
  437. package/cli/lamps/mac-starter/.lamp/meta.json +1 -0
  438. package/cli/lamps/mac-starter/APP.md +12 -0
  439. package/cli/lamps/mac-starter/Package.swift +8 -0
  440. package/cli/lamps/mac-starter/Sources/App.swift +11 -0
  441. package/cli/lamps/mac-starter/Sources/ContentView.swift +17 -0
  442. package/cli/lamps/mac-starter/Sources/LampSupport.swift +18215 -0
  443. package/cli/lamps/mac-starter/build.sh +336 -0
  444. package/cli/lamps/mac-starter/gitignore +3 -0
  445. package/cli/lamps/mac-starter/lamp-starter.json +6 -0
  446. package/cli/lamps/web-starter/APP.md +8 -0
  447. package/cli/lamps/web-starter/app.js +1 -0
  448. package/cli/lamps/web-starter/index.html +17 -0
  449. package/cli/lamps/web-starter/lamp-starter.json +5 -0
  450. package/cli/lamps/web-starter/lamp.js +7082 -0
  451. package/cli/lamps/web-starter/style.css +25 -0
  452. package/cli/link.mjs +202 -0
  453. package/cli/local-ai.mjs +193 -0
  454. package/cli/mac.mjs +621 -0
  455. package/cli/mdns.mjs +205 -0
  456. package/cli/msix.mjs +413 -0
  457. package/cli/network.mjs +209 -0
  458. package/cli/openrouter.mjs +133 -0
  459. package/cli/outside.mjs +203 -0
  460. package/cli/page.js +317 -0
  461. package/cli/place.mjs +298 -0
  462. package/cli/png.mjs +184 -0
  463. package/cli/share.mjs +270 -0
  464. package/cli/skill/SKILL.md +280 -0
  465. package/cli/skills.mjs +71 -0
  466. package/cli/state.mjs +176 -0
  467. package/cli/update.mjs +162 -0
  468. package/package.json +20 -4
  469. package/site/lib/quota.js +59 -0
  470. package/site/lib/shared-wishes.js +1727 -0
@@ -0,0 +1,2003 @@
1
+ import {
2
+ BoxGeometry,
3
+ BufferGeometry,
4
+ Controls,
5
+ CylinderGeometry,
6
+ DoubleSide,
7
+ Euler,
8
+ Float32BufferAttribute,
9
+ Line,
10
+ LineBasicMaterial,
11
+ Matrix4,
12
+ Mesh,
13
+ MeshBasicMaterial,
14
+ Object3D,
15
+ OctahedronGeometry,
16
+ PlaneGeometry,
17
+ Quaternion,
18
+ Raycaster,
19
+ SphereGeometry,
20
+ TorusGeometry,
21
+ Vector3
22
+ } from 'three';
23
+
24
+ const _raycaster = new Raycaster();
25
+
26
+ const _tempVector = new Vector3();
27
+ const _tempVector2 = new Vector3();
28
+ const _tempQuaternion = new Quaternion();
29
+ const _unit = {
30
+ X: new Vector3( 1, 0, 0 ),
31
+ Y: new Vector3( 0, 1, 0 ),
32
+ Z: new Vector3( 0, 0, 1 )
33
+ };
34
+
35
+ /**
36
+ * Fires if any type of change (object or property change) is performed. Property changes
37
+ * are separate events you can add event listeners to. The event type is "propertyname-changed".
38
+ *
39
+ * @event TransformControls#change
40
+ * @type {Object}
41
+ */
42
+ const _changeEvent = { type: 'change' };
43
+
44
+ /**
45
+ * Fires if a pointer (mouse/touch) becomes active.
46
+ *
47
+ * @event TransformControls#mouseDown
48
+ * @type {Object}
49
+ */
50
+ const _mouseDownEvent = { type: 'mouseDown', mode: null };
51
+
52
+ /**
53
+ * Fires if a pointer (mouse/touch) is no longer active.
54
+ *
55
+ * @event TransformControls#mouseUp
56
+ * @type {Object}
57
+ */
58
+ const _mouseUpEvent = { type: 'mouseUp', mode: null };
59
+
60
+ /**
61
+ * Fires if the controlled 3D object is changed.
62
+ *
63
+ * @event TransformControls#objectChange
64
+ * @type {Object}
65
+ */
66
+ const _objectChangeEvent = { type: 'objectChange' };
67
+
68
+ /**
69
+ * This class can be used to transform objects in 3D space by adapting a similar interaction model
70
+ * of DCC tools like Blender. Unlike other controls, it is not intended to transform the scene's camera.
71
+ *
72
+ * `TransformControls` expects that its attached 3D object is part of the scene graph.
73
+ *
74
+ * @augments Controls
75
+ * @three_import import { TransformControls } from 'three/addons/controls/TransformControls.js';
76
+ */
77
+ class TransformControls extends Controls {
78
+
79
+ /**
80
+ * Constructs a new controls instance.
81
+ *
82
+ * @param {Camera} camera - The camera of the rendered scene.
83
+ * @param {?HTMLElement} domElement - The HTML element used for event listeners.
84
+ */
85
+ constructor( camera, domElement = null ) {
86
+
87
+ super( undefined, domElement );
88
+
89
+ const root = new TransformControlsRoot( this );
90
+ this._root = root;
91
+
92
+ const gizmo = new TransformControlsGizmo();
93
+ this._gizmo = gizmo;
94
+ root.add( gizmo );
95
+
96
+ const plane = new TransformControlsPlane();
97
+ this._plane = plane;
98
+ root.add( plane );
99
+
100
+ const scope = this;
101
+
102
+ // Defined getter, setter and store for a property
103
+ function defineProperty( propName, defaultValue ) {
104
+
105
+ let propValue = defaultValue;
106
+
107
+ Object.defineProperty( scope, propName, {
108
+
109
+ get: function () {
110
+
111
+ return propValue !== undefined ? propValue : defaultValue;
112
+
113
+ },
114
+
115
+ set: function ( value ) {
116
+
117
+ if ( propValue !== value ) {
118
+
119
+ propValue = value;
120
+ plane[ propName ] = value;
121
+ gizmo[ propName ] = value;
122
+
123
+ scope.dispatchEvent( { type: propName + '-changed', value: value } );
124
+ scope.dispatchEvent( _changeEvent );
125
+
126
+ }
127
+
128
+ }
129
+
130
+ } );
131
+
132
+ scope[ propName ] = defaultValue;
133
+ plane[ propName ] = defaultValue;
134
+ gizmo[ propName ] = defaultValue;
135
+
136
+ }
137
+
138
+ // Define properties with getters/setter
139
+ // Setting the defined property will automatically trigger change event
140
+ // Defined properties are passed down to gizmo and plane
141
+
142
+ /**
143
+ * The camera of the rendered scene.
144
+ *
145
+ * @name TransformControls#camera
146
+ * @type {Camera}
147
+ */
148
+ defineProperty( 'camera', camera );
149
+ defineProperty( 'object', undefined );
150
+ defineProperty( 'enabled', true );
151
+
152
+ /**
153
+ * The current transformation axis.
154
+ *
155
+ * @name TransformControls#axis
156
+ * @type {string}
157
+ */
158
+ defineProperty( 'axis', null );
159
+
160
+ /**
161
+ * The current transformation axis.
162
+ *
163
+ * @name TransformControls#mode
164
+ * @type {('translate'|'rotate'|'scale')}
165
+ * @default 'translate'
166
+ */
167
+ defineProperty( 'mode', 'translate' );
168
+
169
+ /**
170
+ * By default, 3D objects are continuously translated. If you set this property to a numeric
171
+ * value (world units), you can define in which steps the 3D object should be translated.
172
+ *
173
+ * @name TransformControls#translationSnap
174
+ * @type {?number}
175
+ * @default null
176
+ */
177
+ defineProperty( 'translationSnap', null );
178
+
179
+ /**
180
+ * By default, 3D objects are continuously rotated. If you set this property to a numeric
181
+ * value (radians), you can define in which steps the 3D object should be rotated.
182
+ *
183
+ * @name TransformControls#rotationSnap
184
+ * @type {?number}
185
+ * @default null
186
+ */
187
+ defineProperty( 'rotationSnap', null );
188
+
189
+ /**
190
+ * By default, 3D objects are continuously scaled. If you set this property to a numeric
191
+ * value, you can define in which steps the 3D object should be scaled.
192
+ *
193
+ * @name TransformControls#scaleSnap
194
+ * @type {?number}
195
+ * @default null
196
+ */
197
+ defineProperty( 'scaleSnap', null );
198
+
199
+ /**
200
+ * Defines in which coordinate space transformations should be performed.
201
+ *
202
+ * @name TransformControls#space
203
+ * @type {('world'|'local')}
204
+ * @default 'world'
205
+ */
206
+ defineProperty( 'space', 'world' );
207
+
208
+ /**
209
+ * The size of the helper UI (axes/planes).
210
+ *
211
+ * @name TransformControls#size
212
+ * @type {number}
213
+ * @default 1
214
+ */
215
+ defineProperty( 'size', 1 );
216
+
217
+ /**
218
+ * The viewport rectangle, in logical (CSS) pixels with the origin at the lower-left
219
+ * of the canvas. Set this when the renderer uses a sub-canvas viewport so pointer
220
+ * coordinates map to the correct region. If `null`, the full canvas is used.
221
+ *
222
+ * @name TransformControls#viewport
223
+ * @type {?Vector4}
224
+ * @default null
225
+ */
226
+ this.viewport = null;
227
+
228
+ /**
229
+ * Whether dragging is currently performed or not.
230
+ *
231
+ * @name TransformControls#dragging
232
+ * @type {boolean}
233
+ * @readonly
234
+ * @default false
235
+ */
236
+ defineProperty( 'dragging', false );
237
+
238
+ /**
239
+ * Whether the x-axis helper should be visible or not.
240
+ *
241
+ * @name TransformControls#showX
242
+ * @type {boolean}
243
+ * @default true
244
+ */
245
+ defineProperty( 'showX', true );
246
+
247
+ /**
248
+ * Whether the y-axis helper should be visible or not.
249
+ *
250
+ * @name TransformControls#showY
251
+ * @type {boolean}
252
+ * @default true
253
+ */
254
+ defineProperty( 'showY', true );
255
+
256
+ /**
257
+ * Whether the z-axis helper should be visible or not.
258
+ *
259
+ * @name TransformControls#showZ
260
+ * @type {boolean}
261
+ * @default true
262
+ */
263
+ defineProperty( 'showZ', true );
264
+
265
+ /**
266
+ * Whether the xy-plane helper should be visible or not.
267
+ *
268
+ * @name TransformControls#showXY
269
+ * @type {boolean}
270
+ * @default true
271
+ */
272
+ defineProperty( 'showXY', true );
273
+
274
+ /**
275
+ * Whether the yz-plane helper should be visible or not.
276
+ *
277
+ * @name TransformControls#showYZ
278
+ * @type {boolean}
279
+ * @default true
280
+ */
281
+ defineProperty( 'showYZ', true );
282
+
283
+ /**
284
+ * Whether the xz-axis helper should be visible or not.
285
+ *
286
+ * @name TransformControls#showXZ
287
+ * @type {boolean}
288
+ * @default true
289
+ */
290
+ defineProperty( 'showXZ', true );
291
+
292
+ /**
293
+ * Whether the xyze rotation helper should be visible or not.
294
+ *
295
+ * @name TransformControls#showXYZE
296
+ * @type {boolean}
297
+ * @default true
298
+ */
299
+ defineProperty( 'showXYZE', true );
300
+
301
+ /**
302
+ * Whether the e rotation helper should be visible or not.
303
+ *
304
+ * @name TransformControls#showE
305
+ * @type {boolean}
306
+ * @default true
307
+ */
308
+ defineProperty( 'showE', true );
309
+
310
+ /**
311
+ * The minimum allowed X position during translation.
312
+ *
313
+ * @name TransformControls#minX
314
+ * @type {number}
315
+ * @default -Infinity
316
+ */
317
+ defineProperty( 'minX', - Infinity );
318
+
319
+ /**
320
+ * The maximum allowed X position during translation.
321
+ *
322
+ * @name TransformControls#maxX
323
+ * @type {number}
324
+ * @default Infinity
325
+ */
326
+ defineProperty( 'maxX', Infinity );
327
+
328
+ /**
329
+ * The minimum allowed y position during translation.
330
+ *
331
+ * @name TransformControls#minY
332
+ * @type {number}
333
+ * @default -Infinity
334
+ */
335
+ defineProperty( 'minY', - Infinity );
336
+
337
+ /**
338
+ * The maximum allowed Y position during translation.
339
+ *
340
+ * @name TransformControls#maxY
341
+ * @type {number}
342
+ * @default Infinity
343
+ */
344
+ defineProperty( 'maxY', Infinity );
345
+
346
+ /**
347
+ * The minimum allowed z position during translation.
348
+ *
349
+ * @name TransformControls#minZ
350
+ * @type {number}
351
+ * @default -Infinity
352
+ */
353
+ defineProperty( 'minZ', - Infinity );
354
+
355
+ /**
356
+ * The maximum allowed Z position during translation.
357
+ *
358
+ * @name TransformControls#maxZ
359
+ * @type {number}
360
+ * @default Infinity
361
+ */
362
+ defineProperty( 'maxZ', Infinity );
363
+
364
+ // Reusable utility variables
365
+
366
+ const worldPosition = new Vector3();
367
+ const worldPositionStart = new Vector3();
368
+ const worldQuaternion = new Quaternion();
369
+ const worldQuaternionStart = new Quaternion();
370
+ const cameraPosition = new Vector3();
371
+ const cameraQuaternion = new Quaternion();
372
+ const pointStart = new Vector3();
373
+ const pointEnd = new Vector3();
374
+ const rotationAxis = new Vector3();
375
+ const rotationAngle = 0;
376
+ const eye = new Vector3();
377
+
378
+ // TODO: remove properties unused in plane and gizmo
379
+
380
+ defineProperty( 'worldPosition', worldPosition );
381
+ defineProperty( 'worldPositionStart', worldPositionStart );
382
+ defineProperty( 'worldQuaternion', worldQuaternion );
383
+ defineProperty( 'worldQuaternionStart', worldQuaternionStart );
384
+ defineProperty( 'cameraPosition', cameraPosition );
385
+ defineProperty( 'cameraQuaternion', cameraQuaternion );
386
+ defineProperty( 'pointStart', pointStart );
387
+ defineProperty( 'pointEnd', pointEnd );
388
+ defineProperty( 'rotationAxis', rotationAxis );
389
+ defineProperty( 'rotationAngle', rotationAngle );
390
+ defineProperty( 'eye', eye );
391
+
392
+ this._offset = new Vector3();
393
+ this._startNorm = new Vector3();
394
+ this._endNorm = new Vector3();
395
+ this._cameraScale = new Vector3();
396
+
397
+ this._parentPosition = new Vector3();
398
+ this._parentQuaternion = new Quaternion();
399
+ this._parentQuaternionInv = new Quaternion();
400
+ this._parentScale = new Vector3();
401
+
402
+ this._worldScaleStart = new Vector3();
403
+ this._worldQuaternionInv = new Quaternion();
404
+ this._worldScale = new Vector3();
405
+
406
+ this._positionStart = new Vector3();
407
+ this._quaternionStart = new Quaternion();
408
+ this._scaleStart = new Vector3();
409
+
410
+ this._getPointer = getPointer.bind( this );
411
+ this._onPointerDown = onPointerDown.bind( this );
412
+ this._onPointerHover = onPointerHover.bind( this );
413
+ this._onPointerMove = onPointerMove.bind( this );
414
+ this._onPointerUp = onPointerUp.bind( this );
415
+
416
+ if ( domElement !== null ) {
417
+
418
+ this.connect( domElement );
419
+
420
+ }
421
+
422
+ }
423
+
424
+ connect( element ) {
425
+
426
+ super.connect( element );
427
+
428
+ this.domElement.addEventListener( 'pointerdown', this._onPointerDown );
429
+ this.domElement.addEventListener( 'pointermove', this._onPointerHover );
430
+ this.domElement.addEventListener( 'pointerup', this._onPointerUp );
431
+
432
+ this.domElement.style.touchAction = 'none'; // Disable touch scroll
433
+
434
+ }
435
+
436
+ disconnect() {
437
+
438
+ this.domElement.removeEventListener( 'pointerdown', this._onPointerDown );
439
+ this.domElement.removeEventListener( 'pointermove', this._onPointerHover );
440
+ this.domElement.removeEventListener( 'pointermove', this._onPointerMove );
441
+ this.domElement.removeEventListener( 'pointerup', this._onPointerUp );
442
+
443
+ this.domElement.style.touchAction = ''; // Restore touch scroll
444
+
445
+ }
446
+
447
+ /**
448
+ * Returns the visual representation of the controls. Add the helper to your scene to
449
+ * visually transform the attached 3D object.
450
+ *
451
+ * @return {TransformControlsRoot} The helper.
452
+ */
453
+ getHelper() {
454
+
455
+ return this._root;
456
+
457
+ }
458
+
459
+ pointerHover( pointer ) {
460
+
461
+ if ( this.object === undefined || this.dragging === true ) return;
462
+
463
+ if ( pointer !== null ) _raycaster.setFromCamera( pointer, this.camera );
464
+
465
+ const intersect = intersectObjectWithRay( this._gizmo.picker[ this.mode ], _raycaster );
466
+
467
+ if ( intersect ) {
468
+
469
+ this.axis = intersect.object.name;
470
+
471
+ } else {
472
+
473
+ this.axis = null;
474
+
475
+ }
476
+
477
+ }
478
+
479
+ pointerDown( pointer ) {
480
+
481
+ if ( this.object === undefined || this.dragging === true || ( pointer != null && pointer.button !== 0 ) ) return;
482
+
483
+ if ( this.axis !== null ) {
484
+
485
+ if ( pointer !== null ) _raycaster.setFromCamera( pointer, this.camera );
486
+
487
+ const planeIntersect = intersectObjectWithRay( this._plane, _raycaster, true );
488
+
489
+ if ( planeIntersect ) {
490
+
491
+ this.object.updateMatrixWorld();
492
+ this.object.parent.updateMatrixWorld();
493
+
494
+ this._positionStart.copy( this.object.position );
495
+ this._quaternionStart.copy( this.object.quaternion );
496
+ this._scaleStart.copy( this.object.scale );
497
+
498
+ this.object.matrixWorld.decompose( this.worldPositionStart, this.worldQuaternionStart, this._worldScaleStart );
499
+
500
+ this.pointStart.copy( planeIntersect.point ).sub( this.worldPositionStart );
501
+
502
+ }
503
+
504
+ this.dragging = true;
505
+ _mouseDownEvent.mode = this.mode;
506
+ this.dispatchEvent( _mouseDownEvent );
507
+
508
+ }
509
+
510
+ }
511
+
512
+ pointerMove( pointer ) {
513
+
514
+ const axis = this.axis;
515
+ const mode = this.mode;
516
+ const object = this.object;
517
+ let space = this.space;
518
+
519
+ if ( mode === 'scale' ) {
520
+
521
+ space = 'local';
522
+
523
+ } else if ( axis === 'E' || axis === 'XYZE' || axis === 'XYZ' ) {
524
+
525
+ space = 'world';
526
+
527
+ }
528
+
529
+ if ( object === undefined || axis === null || this.dragging === false || ( pointer !== null && pointer.button !== - 1 ) ) return;
530
+
531
+ if ( pointer !== null ) _raycaster.setFromCamera( pointer, this.camera );
532
+
533
+ const planeIntersect = intersectObjectWithRay( this._plane, _raycaster, true );
534
+
535
+ if ( ! planeIntersect ) return;
536
+
537
+ this.pointEnd.copy( planeIntersect.point ).sub( this.worldPositionStart );
538
+
539
+ if ( mode === 'translate' ) {
540
+
541
+ // Apply translate
542
+
543
+ this._offset.copy( this.pointEnd ).sub( this.pointStart );
544
+
545
+ if ( space === 'local' && axis !== 'XYZ' ) {
546
+
547
+ this._offset.applyQuaternion( this._worldQuaternionInv );
548
+
549
+ }
550
+
551
+ if ( axis.indexOf( 'X' ) === - 1 ) this._offset.x = 0;
552
+ if ( axis.indexOf( 'Y' ) === - 1 ) this._offset.y = 0;
553
+ if ( axis.indexOf( 'Z' ) === - 1 ) this._offset.z = 0;
554
+
555
+ if ( space === 'local' && axis !== 'XYZ' ) {
556
+
557
+ this._offset.applyQuaternion( this._quaternionStart ).divide( this._parentScale );
558
+
559
+ } else {
560
+
561
+ this._offset.applyQuaternion( this._parentQuaternionInv ).divide( this._parentScale );
562
+
563
+ }
564
+
565
+ object.position.copy( this._offset ).add( this._positionStart );
566
+
567
+ // Apply translation snap
568
+
569
+ if ( this.translationSnap ) {
570
+
571
+ if ( space === 'local' ) {
572
+
573
+ object.position.applyQuaternion( _tempQuaternion.copy( this._quaternionStart ).invert() );
574
+
575
+ if ( axis.search( 'X' ) !== - 1 ) {
576
+
577
+ object.position.x = Math.round( object.position.x / this.translationSnap ) * this.translationSnap;
578
+
579
+ }
580
+
581
+ if ( axis.search( 'Y' ) !== - 1 ) {
582
+
583
+ object.position.y = Math.round( object.position.y / this.translationSnap ) * this.translationSnap;
584
+
585
+ }
586
+
587
+ if ( axis.search( 'Z' ) !== - 1 ) {
588
+
589
+ object.position.z = Math.round( object.position.z / this.translationSnap ) * this.translationSnap;
590
+
591
+ }
592
+
593
+ object.position.applyQuaternion( this._quaternionStart );
594
+
595
+ }
596
+
597
+ if ( space === 'world' ) {
598
+
599
+ object.getWorldPosition( _tempVector );
600
+
601
+ if ( axis.search( 'X' ) !== - 1 ) {
602
+
603
+ _tempVector.x = Math.round( _tempVector.x / this.translationSnap ) * this.translationSnap;
604
+
605
+ }
606
+
607
+ if ( axis.search( 'Y' ) !== - 1 ) {
608
+
609
+ _tempVector.y = Math.round( _tempVector.y / this.translationSnap ) * this.translationSnap;
610
+
611
+ }
612
+
613
+ if ( axis.search( 'Z' ) !== - 1 ) {
614
+
615
+ _tempVector.z = Math.round( _tempVector.z / this.translationSnap ) * this.translationSnap;
616
+
617
+ }
618
+
619
+ object.position.copy( object.parent.worldToLocal( _tempVector ) );
620
+
621
+ }
622
+
623
+ }
624
+
625
+ object.position.x = Math.max( this.minX, Math.min( this.maxX, object.position.x ) );
626
+ object.position.y = Math.max( this.minY, Math.min( this.maxY, object.position.y ) );
627
+ object.position.z = Math.max( this.minZ, Math.min( this.maxZ, object.position.z ) );
628
+
629
+ } else if ( mode === 'scale' ) {
630
+
631
+ if ( axis.search( 'XYZ' ) !== - 1 ) {
632
+
633
+ let d = this.pointEnd.length() / this.pointStart.length();
634
+
635
+ if ( this.pointEnd.dot( this.pointStart ) < 0 ) d *= - 1;
636
+
637
+ _tempVector2.set( d, d, d );
638
+
639
+ } else {
640
+
641
+ _tempVector.copy( this.pointStart );
642
+ _tempVector2.copy( this.pointEnd );
643
+
644
+ _tempVector.applyQuaternion( this._worldQuaternionInv );
645
+ _tempVector2.applyQuaternion( this._worldQuaternionInv );
646
+
647
+ _tempVector2.divide( _tempVector );
648
+
649
+ if ( axis.search( 'X' ) === - 1 ) {
650
+
651
+ _tempVector2.x = 1;
652
+
653
+ }
654
+
655
+ if ( axis.search( 'Y' ) === - 1 ) {
656
+
657
+ _tempVector2.y = 1;
658
+
659
+ }
660
+
661
+ if ( axis.search( 'Z' ) === - 1 ) {
662
+
663
+ _tempVector2.z = 1;
664
+
665
+ }
666
+
667
+ }
668
+
669
+ // Apply scale
670
+
671
+ object.scale.copy( this._scaleStart ).multiply( _tempVector2 );
672
+
673
+ if ( this.scaleSnap ) {
674
+
675
+ if ( axis.search( 'X' ) !== - 1 ) {
676
+
677
+ object.scale.x = Math.round( object.scale.x / this.scaleSnap ) * this.scaleSnap || this.scaleSnap;
678
+
679
+ }
680
+
681
+ if ( axis.search( 'Y' ) !== - 1 ) {
682
+
683
+ object.scale.y = Math.round( object.scale.y / this.scaleSnap ) * this.scaleSnap || this.scaleSnap;
684
+
685
+ }
686
+
687
+ if ( axis.search( 'Z' ) !== - 1 ) {
688
+
689
+ object.scale.z = Math.round( object.scale.z / this.scaleSnap ) * this.scaleSnap || this.scaleSnap;
690
+
691
+ }
692
+
693
+ }
694
+
695
+ } else if ( mode === 'rotate' ) {
696
+
697
+ this._offset.copy( this.pointEnd ).sub( this.pointStart );
698
+
699
+ const ROTATION_SPEED = 20 / this.worldPosition.distanceTo( _tempVector.setFromMatrixPosition( this.camera.matrixWorld ) );
700
+
701
+ let _inPlaneRotation = false;
702
+
703
+ if ( axis === 'XYZE' ) {
704
+
705
+ this.rotationAxis.copy( this._offset ).cross( this.eye ).normalize();
706
+ this.rotationAngle = this._offset.dot( _tempVector.copy( this.rotationAxis ).cross( this.eye ) ) * ROTATION_SPEED;
707
+
708
+ } else if ( axis === 'X' || axis === 'Y' || axis === 'Z' ) {
709
+
710
+ this.rotationAxis.copy( _unit[ axis ] );
711
+
712
+ _tempVector.copy( _unit[ axis ] );
713
+
714
+ if ( space === 'local' ) {
715
+
716
+ _tempVector.applyQuaternion( this.worldQuaternion );
717
+
718
+ }
719
+
720
+ _tempVector.cross( this.eye );
721
+
722
+ // When _tempVector is 0 after cross with this.eye the vectors are parallel and should use in-plane rotation logic.
723
+ if ( _tempVector.length() === 0 ) {
724
+
725
+ _inPlaneRotation = true;
726
+
727
+ } else {
728
+
729
+ this.rotationAngle = this._offset.dot( _tempVector.normalize() ) * ROTATION_SPEED;
730
+
731
+ }
732
+
733
+
734
+ }
735
+
736
+ if ( axis === 'E' || _inPlaneRotation ) {
737
+
738
+ this.rotationAxis.copy( this.eye );
739
+ this.rotationAngle = this.pointEnd.angleTo( this.pointStart );
740
+
741
+ this._startNorm.copy( this.pointStart ).normalize();
742
+ this._endNorm.copy( this.pointEnd ).normalize();
743
+
744
+ this.rotationAngle *= ( this._endNorm.cross( this._startNorm ).dot( this.eye ) < 0 ? 1 : - 1 );
745
+
746
+ }
747
+
748
+ // Apply rotation snap
749
+
750
+ if ( this.rotationSnap ) this.rotationAngle = Math.round( this.rotationAngle / this.rotationSnap ) * this.rotationSnap;
751
+
752
+ // Apply rotate
753
+ if ( space === 'local' && axis !== 'E' && axis !== 'XYZE' ) {
754
+
755
+ object.quaternion.copy( this._quaternionStart );
756
+ object.quaternion.multiply( _tempQuaternion.setFromAxisAngle( this.rotationAxis, this.rotationAngle ) ).normalize();
757
+
758
+ } else {
759
+
760
+ this.rotationAxis.applyQuaternion( this._parentQuaternionInv );
761
+ object.quaternion.copy( _tempQuaternion.setFromAxisAngle( this.rotationAxis, this.rotationAngle ) );
762
+ object.quaternion.multiply( this._quaternionStart ).normalize();
763
+
764
+ }
765
+
766
+ }
767
+
768
+ this.dispatchEvent( _changeEvent );
769
+ this.dispatchEvent( _objectChangeEvent );
770
+
771
+ }
772
+
773
+ pointerUp( pointer ) {
774
+
775
+ if ( pointer !== null && pointer.button !== 0 ) return;
776
+
777
+ if ( this.dragging && ( this.axis !== null ) ) {
778
+
779
+ _mouseUpEvent.mode = this.mode;
780
+ this.dispatchEvent( _mouseUpEvent );
781
+
782
+ }
783
+
784
+ this.dragging = false;
785
+ this.axis = null;
786
+
787
+ }
788
+
789
+ dispose() {
790
+
791
+ this.disconnect();
792
+
793
+ this._root.dispose();
794
+
795
+ }
796
+
797
+ /**
798
+ * Sets the 3D object that should be transformed and ensures the controls UI is visible.
799
+ *
800
+ * @param {Object3D} object - The 3D object that should be transformed.
801
+ * @return {TransformControls} A reference to this controls.
802
+ */
803
+ attach( object ) {
804
+
805
+ this.object = object;
806
+ this._root.visible = true;
807
+
808
+ return this;
809
+
810
+ }
811
+
812
+ /**
813
+ * Removes the current 3D object from the controls and makes the helper UI invisible.
814
+ *
815
+ * @return {TransformControls} A reference to this controls.
816
+ */
817
+ detach() {
818
+
819
+ this.object = undefined;
820
+ this.axis = null;
821
+
822
+ this._root.visible = false;
823
+
824
+ return this;
825
+
826
+ }
827
+
828
+ /**
829
+ * Resets the object's position, rotation and scale to when the current transform began.
830
+ */
831
+ reset() {
832
+
833
+ if ( ! this.enabled ) return;
834
+
835
+ if ( this.dragging ) {
836
+
837
+ this.object.position.copy( this._positionStart );
838
+ this.object.quaternion.copy( this._quaternionStart );
839
+ this.object.scale.copy( this._scaleStart );
840
+
841
+ this.dispatchEvent( _changeEvent );
842
+ this.dispatchEvent( _objectChangeEvent );
843
+
844
+ this.pointStart.copy( this.pointEnd );
845
+
846
+ }
847
+
848
+ }
849
+
850
+ /**
851
+ * Returns the raycaster that is used for user interaction. This object is shared between all
852
+ * instances of `TransformControls`.
853
+ *
854
+ * @returns {Raycaster} The internal raycaster.
855
+ */
856
+ getRaycaster() {
857
+
858
+ return _raycaster;
859
+
860
+ }
861
+
862
+ /**
863
+ * Returns the transformation mode.
864
+ *
865
+ * @returns {'translate'|'rotate'|'scale'} The transformation mode.
866
+ */
867
+ getMode() {
868
+
869
+ return this.mode;
870
+
871
+ }
872
+
873
+ /**
874
+ * Sets the given transformation mode.
875
+ *
876
+ * @param {'translate'|'rotate'|'scale'} mode - The transformation mode to set.
877
+ */
878
+ setMode( mode ) {
879
+
880
+ this.mode = mode;
881
+
882
+ }
883
+
884
+ /**
885
+ * Sets the translation snap.
886
+ *
887
+ * @param {?number} translationSnap - The translation snap to set.
888
+ */
889
+ setTranslationSnap( translationSnap ) {
890
+
891
+ this.translationSnap = translationSnap;
892
+
893
+ }
894
+
895
+ /**
896
+ * Sets the rotation snap.
897
+ *
898
+ * @param {?number} rotationSnap - The rotation snap to set.
899
+ */
900
+ setRotationSnap( rotationSnap ) {
901
+
902
+ this.rotationSnap = rotationSnap;
903
+
904
+ }
905
+
906
+ /**
907
+ * Sets the scale snap.
908
+ *
909
+ * @param {?number} scaleSnap - The scale snap to set.
910
+ */
911
+ setScaleSnap( scaleSnap ) {
912
+
913
+ this.scaleSnap = scaleSnap;
914
+
915
+ }
916
+
917
+ /**
918
+ * Sets the size of the helper UI.
919
+ *
920
+ * @param {number} size - The size to set.
921
+ */
922
+ setSize( size ) {
923
+
924
+ this.size = size;
925
+
926
+ }
927
+
928
+ /**
929
+ * Sets the coordinate space in which transformations are applied.
930
+ *
931
+ * @param {'world'|'local'} space - The space to set.
932
+ */
933
+ setSpace( space ) {
934
+
935
+ this.space = space;
936
+
937
+ }
938
+
939
+ /**
940
+ * Sets the colors of the control's gizmo.
941
+ *
942
+ * @param {number|Color|string} xAxis - The x-axis color.
943
+ * @param {number|Color|string} yAxis - The y-axis color.
944
+ * @param {number|Color|string} zAxis - The z-axis color.
945
+ * @param {number|Color|string} active - The color for active elements.
946
+ */
947
+ setColors( xAxis, yAxis, zAxis, active ) {
948
+
949
+ const materialLib = this._gizmo.materialLib;
950
+
951
+ materialLib.xAxis.color.set( xAxis );
952
+ materialLib.yAxis.color.set( yAxis );
953
+ materialLib.zAxis.color.set( zAxis );
954
+ materialLib.active.color.set( active );
955
+ materialLib.xAxisTransparent.color.set( xAxis );
956
+ materialLib.yAxisTransparent.color.set( yAxis );
957
+ materialLib.zAxisTransparent.color.set( zAxis );
958
+ materialLib.activeTransparent.color.set( active );
959
+
960
+ // update color caches
961
+
962
+ if ( materialLib.xAxis._color ) materialLib.xAxis._color.set( xAxis );
963
+ if ( materialLib.yAxis._color ) materialLib.yAxis._color.set( yAxis );
964
+ if ( materialLib.zAxis._color ) materialLib.zAxis._color.set( zAxis );
965
+ if ( materialLib.active._color ) materialLib.active._color.set( active );
966
+ if ( materialLib.xAxisTransparent._color ) materialLib.xAxisTransparent._color.set( xAxis );
967
+ if ( materialLib.yAxisTransparent._color ) materialLib.yAxisTransparent._color.set( yAxis );
968
+ if ( materialLib.zAxisTransparent._color ) materialLib.zAxisTransparent._color.set( zAxis );
969
+ if ( materialLib.activeTransparent._color ) materialLib.activeTransparent._color.set( active );
970
+
971
+ }
972
+
973
+ }
974
+
975
+ // mouse / touch event handlers
976
+
977
+ function getPointer( event ) {
978
+
979
+ if ( this.domElement.ownerDocument.pointerLockElement ) {
980
+
981
+ return {
982
+ x: 0,
983
+ y: 0,
984
+ button: event.button
985
+ };
986
+
987
+ } else {
988
+
989
+ const rect = this.domElement.getBoundingClientRect();
990
+ const viewport = this.viewport;
991
+
992
+ let originX, originY, regionWidth, regionHeight;
993
+
994
+ if ( viewport !== null ) {
995
+
996
+ originX = viewport.x;
997
+ originY = rect.height - viewport.y - viewport.w;
998
+ regionWidth = viewport.z;
999
+ regionHeight = viewport.w;
1000
+
1001
+ } else {
1002
+
1003
+ originX = 0;
1004
+ originY = 0;
1005
+ regionWidth = rect.width;
1006
+ regionHeight = rect.height;
1007
+
1008
+ }
1009
+
1010
+ return {
1011
+ x: ( event.clientX - rect.left - originX ) / regionWidth * 2 - 1,
1012
+ y: - ( event.clientY - rect.top - originY ) / regionHeight * 2 + 1,
1013
+ button: event.button
1014
+ };
1015
+
1016
+ }
1017
+
1018
+ }
1019
+
1020
+ function onPointerHover( event ) {
1021
+
1022
+ if ( ! this.enabled ) return;
1023
+
1024
+ switch ( event.pointerType ) {
1025
+
1026
+ case 'mouse':
1027
+ case 'pen':
1028
+ this.pointerHover( this._getPointer( event ) );
1029
+ break;
1030
+
1031
+ }
1032
+
1033
+ }
1034
+
1035
+ function onPointerDown( event ) {
1036
+
1037
+ if ( ! this.enabled ) return;
1038
+
1039
+ if ( ! document.pointerLockElement ) {
1040
+
1041
+ this.domElement.setPointerCapture( event.pointerId );
1042
+
1043
+ }
1044
+
1045
+ this.domElement.addEventListener( 'pointermove', this._onPointerMove );
1046
+
1047
+ this.pointerHover( this._getPointer( event ) );
1048
+ this.pointerDown( this._getPointer( event ) );
1049
+
1050
+ }
1051
+
1052
+ function onPointerMove( event ) {
1053
+
1054
+ if ( ! this.enabled ) return;
1055
+
1056
+ this.pointerMove( this._getPointer( event ) );
1057
+
1058
+ }
1059
+
1060
+ function onPointerUp( event ) {
1061
+
1062
+ if ( ! this.enabled ) return;
1063
+
1064
+ this.domElement.releasePointerCapture( event.pointerId );
1065
+
1066
+ this.domElement.removeEventListener( 'pointermove', this._onPointerMove );
1067
+
1068
+ this.pointerUp( this._getPointer( event ) );
1069
+
1070
+ }
1071
+
1072
+ function intersectObjectWithRay( object, raycaster, includeInvisible ) {
1073
+
1074
+ const allIntersections = raycaster.intersectObject( object, true );
1075
+
1076
+ for ( let i = 0; i < allIntersections.length; i ++ ) {
1077
+
1078
+ if ( allIntersections[ i ].object.visible || includeInvisible ) {
1079
+
1080
+ return allIntersections[ i ];
1081
+
1082
+ }
1083
+
1084
+ }
1085
+
1086
+ return false;
1087
+
1088
+ }
1089
+
1090
+ //
1091
+
1092
+ // Reusable utility variables
1093
+
1094
+ const _tempEuler = new Euler();
1095
+ const _alignVector = new Vector3( 0, 1, 0 );
1096
+ const _zeroVector = new Vector3( 0, 0, 0 );
1097
+ const _lookAtMatrix = new Matrix4();
1098
+ const _tempQuaternion2 = new Quaternion();
1099
+ const _identityQuaternion = new Quaternion();
1100
+ const _dirVector = new Vector3();
1101
+ const _tempMatrix = new Matrix4();
1102
+
1103
+ const _unitX = new Vector3( 1, 0, 0 );
1104
+ const _unitY = new Vector3( 0, 1, 0 );
1105
+ const _unitZ = new Vector3( 0, 0, 1 );
1106
+
1107
+ const _v1 = new Vector3();
1108
+ const _v2 = new Vector3();
1109
+ const _v3 = new Vector3();
1110
+
1111
+ class TransformControlsRoot extends Object3D {
1112
+
1113
+ constructor( controls ) {
1114
+
1115
+ super();
1116
+
1117
+ this.isTransformControlsRoot = true;
1118
+
1119
+ this.controls = controls;
1120
+ this.visible = false;
1121
+
1122
+ }
1123
+
1124
+ // updateMatrixWorld updates key transformation variables
1125
+ updateMatrixWorld( force ) {
1126
+
1127
+ const controls = this.controls;
1128
+
1129
+ if ( controls.object !== undefined ) {
1130
+
1131
+ controls.object.updateMatrixWorld();
1132
+
1133
+ if ( controls.object.parent === null ) {
1134
+
1135
+ console.error( 'TransformControls: The attached 3D object must be a part of the scene graph.' );
1136
+
1137
+ } else {
1138
+
1139
+ controls.object.parent.matrixWorld.decompose( controls._parentPosition, controls._parentQuaternion, controls._parentScale );
1140
+
1141
+ }
1142
+
1143
+ controls.object.matrixWorld.decompose( controls.worldPosition, controls.worldQuaternion, controls._worldScale );
1144
+
1145
+ controls._parentQuaternionInv.copy( controls._parentQuaternion ).invert();
1146
+ controls._worldQuaternionInv.copy( controls.worldQuaternion ).invert();
1147
+
1148
+ }
1149
+
1150
+ controls.camera.updateMatrixWorld();
1151
+ controls.camera.matrixWorld.decompose( controls.cameraPosition, controls.cameraQuaternion, controls._cameraScale );
1152
+
1153
+ if ( controls.camera.isOrthographicCamera ) {
1154
+
1155
+ controls.camera.getWorldDirection( controls.eye ).negate();
1156
+
1157
+ } else {
1158
+
1159
+ controls.eye.copy( controls.cameraPosition ).sub( controls.worldPosition ).normalize();
1160
+
1161
+ }
1162
+
1163
+ // Cancel out the parent's transform so the gizmo stays world-aligned.
1164
+
1165
+ if ( this.parent ) {
1166
+
1167
+ _tempMatrix.copy( this.parent.matrixWorld ).invert();
1168
+ _tempMatrix.decompose( this.position, this.quaternion, this.scale );
1169
+
1170
+ }
1171
+
1172
+ super.updateMatrixWorld( force );
1173
+
1174
+ }
1175
+
1176
+ dispose() {
1177
+
1178
+ this.traverse( function ( child ) {
1179
+
1180
+ if ( child.geometry ) child.geometry.dispose();
1181
+ if ( child.material ) child.material.dispose();
1182
+
1183
+ } );
1184
+
1185
+ }
1186
+
1187
+ }
1188
+
1189
+ class TransformControlsGizmo extends Object3D {
1190
+
1191
+ constructor() {
1192
+
1193
+ super();
1194
+
1195
+ this.isTransformControlsGizmo = true;
1196
+
1197
+ this.type = 'TransformControlsGizmo';
1198
+
1199
+ // shared materials
1200
+
1201
+ const gizmoMaterial = new MeshBasicMaterial( {
1202
+ depthTest: false,
1203
+ depthWrite: false,
1204
+ fog: false,
1205
+ toneMapped: false,
1206
+ transparent: true
1207
+ } );
1208
+
1209
+ const gizmoLineMaterial = new LineBasicMaterial( {
1210
+ depthTest: false,
1211
+ depthWrite: false,
1212
+ fog: false,
1213
+ toneMapped: false,
1214
+ transparent: true
1215
+ } );
1216
+
1217
+ // Make unique material for each axis/color
1218
+
1219
+ const matInvisible = gizmoMaterial.clone();
1220
+ matInvisible.opacity = 0.15;
1221
+
1222
+ const matHelper = gizmoLineMaterial.clone();
1223
+ matHelper.opacity = 0.5;
1224
+
1225
+ const matRed = gizmoMaterial.clone();
1226
+ matRed.color.setHex( 0xff0000 );
1227
+
1228
+ const matGreen = gizmoMaterial.clone();
1229
+ matGreen.color.setHex( 0x00ff00 );
1230
+
1231
+ const matBlue = gizmoMaterial.clone();
1232
+ matBlue.color.setHex( 0x0000ff );
1233
+
1234
+ const matRedTransparent = gizmoMaterial.clone();
1235
+ matRedTransparent.color.setHex( 0xff0000 );
1236
+ matRedTransparent.opacity = 0.5;
1237
+
1238
+ const matGreenTransparent = gizmoMaterial.clone();
1239
+ matGreenTransparent.color.setHex( 0x00ff00 );
1240
+ matGreenTransparent.opacity = 0.5;
1241
+
1242
+ const matBlueTransparent = gizmoMaterial.clone();
1243
+ matBlueTransparent.color.setHex( 0x0000ff );
1244
+ matBlueTransparent.opacity = 0.5;
1245
+
1246
+ const matWhiteTransparent = gizmoMaterial.clone();
1247
+ matWhiteTransparent.opacity = 0.25;
1248
+
1249
+ const matYellowTransparent = gizmoMaterial.clone();
1250
+ matYellowTransparent.color.setHex( 0xffff00 );
1251
+ matYellowTransparent.opacity = 0.25;
1252
+
1253
+ const matYellow = gizmoMaterial.clone();
1254
+ matYellow.color.setHex( 0xffff00 );
1255
+
1256
+ const matGray = gizmoMaterial.clone();
1257
+ matGray.color.setHex( 0x787878 );
1258
+
1259
+ // materials in the below property are configurable via setColors()
1260
+
1261
+ this.materialLib = {
1262
+ xAxis: matRed,
1263
+ yAxis: matGreen,
1264
+ zAxis: matBlue,
1265
+ active: matYellow,
1266
+ xAxisTransparent: matRedTransparent,
1267
+ yAxisTransparent: matGreenTransparent,
1268
+ zAxisTransparent: matBlueTransparent,
1269
+ activeTransparent: matYellowTransparent
1270
+ };
1271
+
1272
+ // reusable geometry
1273
+
1274
+ const arrowGeometry = new CylinderGeometry( 0, 0.04, 0.1, 12 );
1275
+ arrowGeometry.translate( 0, 0.05, 0 );
1276
+
1277
+ const scaleHandleGeometry = new BoxGeometry( 0.08, 0.08, 0.08 );
1278
+ scaleHandleGeometry.translate( 0, 0.04, 0 );
1279
+
1280
+ const lineGeometry = new BufferGeometry();
1281
+ lineGeometry.setAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 1, 0, 0 ], 3 ) );
1282
+
1283
+ const lineGeometry2 = new CylinderGeometry( 0.0075, 0.0075, 0.5, 3 );
1284
+ lineGeometry2.translate( 0, 0.25, 0 );
1285
+
1286
+ function CircleGeometry( radius, arc ) {
1287
+
1288
+ const geometry = new TorusGeometry( radius, 0.0075, 3, 64, arc * Math.PI * 2 );
1289
+ geometry.rotateY( Math.PI / 2 );
1290
+ geometry.rotateX( Math.PI / 2 );
1291
+ return geometry;
1292
+
1293
+ }
1294
+
1295
+ // Special geometry for transform helper. If scaled with position vector it spans from [0,0,0] to position
1296
+
1297
+ function TranslateHelperGeometry() {
1298
+
1299
+ const geometry = new BufferGeometry();
1300
+
1301
+ geometry.setAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 1, 1, 1 ], 3 ) );
1302
+
1303
+ return geometry;
1304
+
1305
+ }
1306
+
1307
+ // Gizmo definitions - custom hierarchy definitions for setupGizmo() function
1308
+
1309
+ const gizmoTranslate = {
1310
+ X: [
1311
+ [ new Mesh( arrowGeometry, matRed ), [ 0.5, 0, 0 ], [ 0, 0, - Math.PI / 2 ]],
1312
+ [ new Mesh( arrowGeometry, matRed ), [ - 0.5, 0, 0 ], [ 0, 0, Math.PI / 2 ]],
1313
+ [ new Mesh( lineGeometry2, matRed ), [ 0, 0, 0 ], [ 0, 0, - Math.PI / 2 ]]
1314
+ ],
1315
+ Y: [
1316
+ [ new Mesh( arrowGeometry, matGreen ), [ 0, 0.5, 0 ]],
1317
+ [ new Mesh( arrowGeometry, matGreen ), [ 0, - 0.5, 0 ], [ Math.PI, 0, 0 ]],
1318
+ [ new Mesh( lineGeometry2, matGreen ) ]
1319
+ ],
1320
+ Z: [
1321
+ [ new Mesh( arrowGeometry, matBlue ), [ 0, 0, 0.5 ], [ Math.PI / 2, 0, 0 ]],
1322
+ [ new Mesh( arrowGeometry, matBlue ), [ 0, 0, - 0.5 ], [ - Math.PI / 2, 0, 0 ]],
1323
+ [ new Mesh( lineGeometry2, matBlue ), null, [ Math.PI / 2, 0, 0 ]]
1324
+ ],
1325
+ XYZ: [
1326
+ [ new Mesh( new OctahedronGeometry( 0.1, 0 ), matWhiteTransparent ), [ 0, 0, 0 ]]
1327
+ ],
1328
+ XY: [
1329
+ [ new Mesh( new BoxGeometry( 0.15, 0.15, 0.01 ), matBlueTransparent ), [ 0.15, 0.15, 0 ]]
1330
+ ],
1331
+ YZ: [
1332
+ [ new Mesh( new BoxGeometry( 0.15, 0.15, 0.01 ), matRedTransparent ), [ 0, 0.15, 0.15 ], [ 0, Math.PI / 2, 0 ]]
1333
+ ],
1334
+ XZ: [
1335
+ [ new Mesh( new BoxGeometry( 0.15, 0.15, 0.01 ), matGreenTransparent ), [ 0.15, 0, 0.15 ], [ - Math.PI / 2, 0, 0 ]]
1336
+ ]
1337
+ };
1338
+
1339
+ const pickerTranslate = {
1340
+ X: [
1341
+ [ new Mesh( new CylinderGeometry( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0.3, 0, 0 ], [ 0, 0, - Math.PI / 2 ]],
1342
+ [ new Mesh( new CylinderGeometry( 0.2, 0, 0.6, 4 ), matInvisible ), [ - 0.3, 0, 0 ], [ 0, 0, Math.PI / 2 ]]
1343
+ ],
1344
+ Y: [
1345
+ [ new Mesh( new CylinderGeometry( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, 0.3, 0 ]],
1346
+ [ new Mesh( new CylinderGeometry( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, - 0.3, 0 ], [ 0, 0, Math.PI ]]
1347
+ ],
1348
+ Z: [
1349
+ [ new Mesh( new CylinderGeometry( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, 0, 0.3 ], [ Math.PI / 2, 0, 0 ]],
1350
+ [ new Mesh( new CylinderGeometry( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, 0, - 0.3 ], [ - Math.PI / 2, 0, 0 ]]
1351
+ ],
1352
+ XYZ: [
1353
+ [ new Mesh( new OctahedronGeometry( 0.2, 0 ), matInvisible ) ]
1354
+ ],
1355
+ XY: [
1356
+ [ new Mesh( new BoxGeometry( 0.2, 0.2, 0.01 ), matInvisible ), [ 0.15, 0.15, 0 ]]
1357
+ ],
1358
+ YZ: [
1359
+ [ new Mesh( new BoxGeometry( 0.2, 0.2, 0.01 ), matInvisible ), [ 0, 0.15, 0.15 ], [ 0, Math.PI / 2, 0 ]]
1360
+ ],
1361
+ XZ: [
1362
+ [ new Mesh( new BoxGeometry( 0.2, 0.2, 0.01 ), matInvisible ), [ 0.15, 0, 0.15 ], [ - Math.PI / 2, 0, 0 ]]
1363
+ ]
1364
+ };
1365
+
1366
+ const helperTranslate = {
1367
+ START: [
1368
+ [ new Mesh( new OctahedronGeometry( 0.01, 2 ), matHelper ), null, null, null, 'helper' ]
1369
+ ],
1370
+ END: [
1371
+ [ new Mesh( new OctahedronGeometry( 0.01, 2 ), matHelper ), null, null, null, 'helper' ]
1372
+ ],
1373
+ DELTA: [
1374
+ [ new Line( TranslateHelperGeometry(), matHelper ), null, null, null, 'helper' ]
1375
+ ],
1376
+ X: [
1377
+ [ new Line( lineGeometry, matHelper ), [ - 1e3, 0, 0 ], null, [ 1e6, 1, 1 ], 'helper' ]
1378
+ ],
1379
+ Y: [
1380
+ [ new Line( lineGeometry, matHelper ), [ 0, - 1e3, 0 ], [ 0, 0, Math.PI / 2 ], [ 1e6, 1, 1 ], 'helper' ]
1381
+ ],
1382
+ Z: [
1383
+ [ new Line( lineGeometry, matHelper ), [ 0, 0, - 1e3 ], [ 0, - Math.PI / 2, 0 ], [ 1e6, 1, 1 ], 'helper' ]
1384
+ ]
1385
+ };
1386
+
1387
+ const gizmoRotate = {
1388
+ XYZE: [
1389
+ [ new Mesh( CircleGeometry( 0.5, 1 ), matGray ), null, [ 0, Math.PI / 2, 0 ]]
1390
+ ],
1391
+ X: [
1392
+ [ new Mesh( CircleGeometry( 0.5, 0.5 ), matRed ) ]
1393
+ ],
1394
+ Y: [
1395
+ [ new Mesh( CircleGeometry( 0.5, 0.5 ), matGreen ), null, [ 0, 0, - Math.PI / 2 ]]
1396
+ ],
1397
+ Z: [
1398
+ [ new Mesh( CircleGeometry( 0.5, 0.5 ), matBlue ), null, [ 0, Math.PI / 2, 0 ]]
1399
+ ],
1400
+ E: [
1401
+ [ new Mesh( CircleGeometry( 0.75, 1 ), matYellowTransparent ), null, [ 0, Math.PI / 2, 0 ]]
1402
+ ]
1403
+ };
1404
+
1405
+ const helperRotate = {
1406
+ AXIS: [
1407
+ [ new Line( lineGeometry, matHelper ), [ - 1e3, 0, 0 ], null, [ 1e6, 1, 1 ], 'helper' ]
1408
+ ]
1409
+ };
1410
+
1411
+ const pickerRotate = {
1412
+ XYZE: [
1413
+ [ new Mesh( new SphereGeometry( 0.25, 10, 8 ), matInvisible ) ]
1414
+ ],
1415
+ X: [
1416
+ [ new Mesh( new TorusGeometry( 0.5, 0.1, 4, 24 ), matInvisible ), [ 0, 0, 0 ], [ 0, - Math.PI / 2, - Math.PI / 2 ]],
1417
+ ],
1418
+ Y: [
1419
+ [ new Mesh( new TorusGeometry( 0.5, 0.1, 4, 24 ), matInvisible ), [ 0, 0, 0 ], [ Math.PI / 2, 0, 0 ]],
1420
+ ],
1421
+ Z: [
1422
+ [ new Mesh( new TorusGeometry( 0.5, 0.1, 4, 24 ), matInvisible ), [ 0, 0, 0 ], [ 0, 0, - Math.PI / 2 ]],
1423
+ ],
1424
+ E: [
1425
+ [ new Mesh( new TorusGeometry( 0.75, 0.1, 2, 24 ), matInvisible ) ]
1426
+ ]
1427
+ };
1428
+
1429
+ const gizmoScale = {
1430
+ X: [
1431
+ [ new Mesh( scaleHandleGeometry, matRed ), [ 0.5, 0, 0 ], [ 0, 0, - Math.PI / 2 ]],
1432
+ [ new Mesh( lineGeometry2, matRed ), [ 0, 0, 0 ], [ 0, 0, - Math.PI / 2 ]],
1433
+ [ new Mesh( scaleHandleGeometry, matRed ), [ - 0.5, 0, 0 ], [ 0, 0, Math.PI / 2 ]],
1434
+ ],
1435
+ Y: [
1436
+ [ new Mesh( scaleHandleGeometry, matGreen ), [ 0, 0.5, 0 ]],
1437
+ [ new Mesh( lineGeometry2, matGreen ) ],
1438
+ [ new Mesh( scaleHandleGeometry, matGreen ), [ 0, - 0.5, 0 ], [ 0, 0, Math.PI ]],
1439
+ ],
1440
+ Z: [
1441
+ [ new Mesh( scaleHandleGeometry, matBlue ), [ 0, 0, 0.5 ], [ Math.PI / 2, 0, 0 ]],
1442
+ [ new Mesh( lineGeometry2, matBlue ), [ 0, 0, 0 ], [ Math.PI / 2, 0, 0 ]],
1443
+ [ new Mesh( scaleHandleGeometry, matBlue ), [ 0, 0, - 0.5 ], [ - Math.PI / 2, 0, 0 ]]
1444
+ ],
1445
+ XY: [
1446
+ [ new Mesh( new BoxGeometry( 0.15, 0.15, 0.01 ), matBlueTransparent ), [ 0.15, 0.15, 0 ]]
1447
+ ],
1448
+ YZ: [
1449
+ [ new Mesh( new BoxGeometry( 0.15, 0.15, 0.01 ), matRedTransparent ), [ 0, 0.15, 0.15 ], [ 0, Math.PI / 2, 0 ]]
1450
+ ],
1451
+ XZ: [
1452
+ [ new Mesh( new BoxGeometry( 0.15, 0.15, 0.01 ), matGreenTransparent ), [ 0.15, 0, 0.15 ], [ - Math.PI / 2, 0, 0 ]]
1453
+ ],
1454
+ XYZ: [
1455
+ [ new Mesh( new BoxGeometry( 0.1, 0.1, 0.1 ), matWhiteTransparent ) ],
1456
+ ]
1457
+ };
1458
+
1459
+ const pickerScale = {
1460
+ X: [
1461
+ [ new Mesh( new CylinderGeometry( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0.3, 0, 0 ], [ 0, 0, - Math.PI / 2 ]],
1462
+ [ new Mesh( new CylinderGeometry( 0.2, 0, 0.6, 4 ), matInvisible ), [ - 0.3, 0, 0 ], [ 0, 0, Math.PI / 2 ]]
1463
+ ],
1464
+ Y: [
1465
+ [ new Mesh( new CylinderGeometry( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, 0.3, 0 ]],
1466
+ [ new Mesh( new CylinderGeometry( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, - 0.3, 0 ], [ 0, 0, Math.PI ]]
1467
+ ],
1468
+ Z: [
1469
+ [ new Mesh( new CylinderGeometry( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, 0, 0.3 ], [ Math.PI / 2, 0, 0 ]],
1470
+ [ new Mesh( new CylinderGeometry( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, 0, - 0.3 ], [ - Math.PI / 2, 0, 0 ]]
1471
+ ],
1472
+ XY: [
1473
+ [ new Mesh( new BoxGeometry( 0.2, 0.2, 0.01 ), matInvisible ), [ 0.15, 0.15, 0 ]],
1474
+ ],
1475
+ YZ: [
1476
+ [ new Mesh( new BoxGeometry( 0.2, 0.2, 0.01 ), matInvisible ), [ 0, 0.15, 0.15 ], [ 0, Math.PI / 2, 0 ]],
1477
+ ],
1478
+ XZ: [
1479
+ [ new Mesh( new BoxGeometry( 0.2, 0.2, 0.01 ), matInvisible ), [ 0.15, 0, 0.15 ], [ - Math.PI / 2, 0, 0 ]],
1480
+ ],
1481
+ XYZ: [
1482
+ [ new Mesh( new BoxGeometry( 0.2, 0.2, 0.2 ), matInvisible ), [ 0, 0, 0 ]],
1483
+ ]
1484
+ };
1485
+
1486
+ const helperScale = {
1487
+ X: [
1488
+ [ new Line( lineGeometry, matHelper ), [ - 1e3, 0, 0 ], null, [ 1e6, 1, 1 ], 'helper' ]
1489
+ ],
1490
+ Y: [
1491
+ [ new Line( lineGeometry, matHelper ), [ 0, - 1e3, 0 ], [ 0, 0, Math.PI / 2 ], [ 1e6, 1, 1 ], 'helper' ]
1492
+ ],
1493
+ Z: [
1494
+ [ new Line( lineGeometry, matHelper ), [ 0, 0, - 1e3 ], [ 0, - Math.PI / 2, 0 ], [ 1e6, 1, 1 ], 'helper' ]
1495
+ ]
1496
+ };
1497
+
1498
+ // Creates an Object3D with gizmos described in custom hierarchy definition.
1499
+
1500
+ function setupGizmo( gizmoMap ) {
1501
+
1502
+ const gizmo = new Object3D();
1503
+
1504
+ for ( const name in gizmoMap ) {
1505
+
1506
+ for ( let i = gizmoMap[ name ].length; i --; ) {
1507
+
1508
+ const object = gizmoMap[ name ][ i ][ 0 ].clone();
1509
+ const position = gizmoMap[ name ][ i ][ 1 ];
1510
+ const rotation = gizmoMap[ name ][ i ][ 2 ];
1511
+ const scale = gizmoMap[ name ][ i ][ 3 ];
1512
+ const tag = gizmoMap[ name ][ i ][ 4 ];
1513
+
1514
+ // name and tag properties are essential for picking and updating logic.
1515
+ object.name = name;
1516
+ object.tag = tag;
1517
+
1518
+ if ( position ) {
1519
+
1520
+ object.position.set( position[ 0 ], position[ 1 ], position[ 2 ] );
1521
+
1522
+ }
1523
+
1524
+ if ( rotation ) {
1525
+
1526
+ object.rotation.set( rotation[ 0 ], rotation[ 1 ], rotation[ 2 ] );
1527
+
1528
+ }
1529
+
1530
+ if ( scale ) {
1531
+
1532
+ object.scale.set( scale[ 0 ], scale[ 1 ], scale[ 2 ] );
1533
+
1534
+ }
1535
+
1536
+ object.updateMatrix();
1537
+
1538
+ const tempGeometry = object.geometry.clone();
1539
+ tempGeometry.applyMatrix4( object.matrix );
1540
+ object.geometry = tempGeometry;
1541
+ object.renderOrder = Infinity;
1542
+
1543
+ object.position.set( 0, 0, 0 );
1544
+ object.rotation.set( 0, 0, 0 );
1545
+ object.scale.set( 1, 1, 1 );
1546
+
1547
+ gizmo.add( object );
1548
+
1549
+ }
1550
+
1551
+ }
1552
+
1553
+ return gizmo;
1554
+
1555
+ }
1556
+
1557
+ // Gizmo creation
1558
+
1559
+ this.gizmo = {};
1560
+ this.picker = {};
1561
+ this.helper = {};
1562
+
1563
+ this.add( this.gizmo[ 'translate' ] = setupGizmo( gizmoTranslate ) );
1564
+ this.add( this.gizmo[ 'rotate' ] = setupGizmo( gizmoRotate ) );
1565
+ this.add( this.gizmo[ 'scale' ] = setupGizmo( gizmoScale ) );
1566
+ this.add( this.picker[ 'translate' ] = setupGizmo( pickerTranslate ) );
1567
+ this.add( this.picker[ 'rotate' ] = setupGizmo( pickerRotate ) );
1568
+ this.add( this.picker[ 'scale' ] = setupGizmo( pickerScale ) );
1569
+ this.add( this.helper[ 'translate' ] = setupGizmo( helperTranslate ) );
1570
+ this.add( this.helper[ 'rotate' ] = setupGizmo( helperRotate ) );
1571
+ this.add( this.helper[ 'scale' ] = setupGizmo( helperScale ) );
1572
+
1573
+ // Pickers should be hidden always
1574
+
1575
+ this.picker[ 'translate' ].visible = false;
1576
+ this.picker[ 'rotate' ].visible = false;
1577
+ this.picker[ 'scale' ].visible = false;
1578
+
1579
+ }
1580
+
1581
+ // updateMatrixWorld will update transformations and appearance of individual handles
1582
+
1583
+ updateMatrixWorld( force ) {
1584
+
1585
+ const space = ( this.mode === 'scale' ) ? 'local' : this.space; // scale always oriented to local rotation
1586
+
1587
+ const quaternion = ( space === 'local' ) ? this.worldQuaternion : _identityQuaternion;
1588
+
1589
+ // Show only gizmos for current transform mode
1590
+
1591
+ this.gizmo[ 'translate' ].visible = this.mode === 'translate';
1592
+ this.gizmo[ 'rotate' ].visible = this.mode === 'rotate';
1593
+ this.gizmo[ 'scale' ].visible = this.mode === 'scale';
1594
+
1595
+ this.helper[ 'translate' ].visible = this.mode === 'translate';
1596
+ this.helper[ 'rotate' ].visible = this.mode === 'rotate';
1597
+ this.helper[ 'scale' ].visible = this.mode === 'scale';
1598
+
1599
+
1600
+ let handles = [];
1601
+ handles = handles.concat( this.picker[ this.mode ].children );
1602
+ handles = handles.concat( this.gizmo[ this.mode ].children );
1603
+ handles = handles.concat( this.helper[ this.mode ].children );
1604
+
1605
+ for ( let i = 0; i < handles.length; i ++ ) {
1606
+
1607
+ const handle = handles[ i ];
1608
+
1609
+ // hide aligned to camera
1610
+
1611
+ handle.visible = true;
1612
+ handle.rotation.set( 0, 0, 0 );
1613
+ handle.position.copy( this.worldPosition );
1614
+
1615
+ let factor;
1616
+
1617
+ if ( this.camera.isOrthographicCamera ) {
1618
+
1619
+ factor = ( this.camera.top - this.camera.bottom ) / this.camera.zoom;
1620
+
1621
+ } else {
1622
+
1623
+ factor = this.worldPosition.distanceTo( this.cameraPosition ) * Math.min( 1.9 * Math.tan( Math.PI * this.camera.fov / 360 ) / this.camera.zoom, 7 );
1624
+
1625
+ }
1626
+
1627
+ handle.scale.set( 1, 1, 1 ).multiplyScalar( factor * this.size / 4 );
1628
+
1629
+ // TODO: simplify helpers and consider decoupling from gizmo
1630
+
1631
+ if ( handle.tag === 'helper' ) {
1632
+
1633
+ handle.visible = false;
1634
+
1635
+ if ( handle.name === 'AXIS' ) {
1636
+
1637
+ handle.visible = !! this.axis;
1638
+
1639
+ if ( this.axis === 'X' ) {
1640
+
1641
+ _tempQuaternion.setFromEuler( _tempEuler.set( 0, 0, 0 ) );
1642
+ handle.quaternion.copy( quaternion ).multiply( _tempQuaternion );
1643
+
1644
+ if ( Math.abs( _alignVector.copy( _unitX ).applyQuaternion( quaternion ).dot( this.eye ) ) > 0.9 ) {
1645
+
1646
+ handle.visible = false;
1647
+
1648
+ }
1649
+
1650
+ }
1651
+
1652
+ if ( this.axis === 'Y' ) {
1653
+
1654
+ _tempQuaternion.setFromEuler( _tempEuler.set( 0, 0, Math.PI / 2 ) );
1655
+ handle.quaternion.copy( quaternion ).multiply( _tempQuaternion );
1656
+
1657
+ if ( Math.abs( _alignVector.copy( _unitY ).applyQuaternion( quaternion ).dot( this.eye ) ) > 0.9 ) {
1658
+
1659
+ handle.visible = false;
1660
+
1661
+ }
1662
+
1663
+ }
1664
+
1665
+ if ( this.axis === 'Z' ) {
1666
+
1667
+ _tempQuaternion.setFromEuler( _tempEuler.set( 0, Math.PI / 2, 0 ) );
1668
+ handle.quaternion.copy( quaternion ).multiply( _tempQuaternion );
1669
+
1670
+ if ( Math.abs( _alignVector.copy( _unitZ ).applyQuaternion( quaternion ).dot( this.eye ) ) > 0.9 ) {
1671
+
1672
+ handle.visible = false;
1673
+
1674
+ }
1675
+
1676
+ }
1677
+
1678
+ if ( this.axis === 'XYZE' ) {
1679
+
1680
+ _tempQuaternion.setFromEuler( _tempEuler.set( 0, Math.PI / 2, 0 ) );
1681
+ _alignVector.copy( this.rotationAxis );
1682
+ handle.quaternion.setFromRotationMatrix( _lookAtMatrix.lookAt( _zeroVector, _alignVector, _unitY ) );
1683
+ handle.quaternion.multiply( _tempQuaternion );
1684
+ handle.visible = this.dragging;
1685
+
1686
+ }
1687
+
1688
+ if ( this.axis === 'E' ) {
1689
+
1690
+ handle.visible = false;
1691
+
1692
+ }
1693
+
1694
+
1695
+ } else if ( handle.name === 'START' ) {
1696
+
1697
+ handle.position.copy( this.worldPositionStart );
1698
+ handle.visible = this.dragging;
1699
+
1700
+ } else if ( handle.name === 'END' ) {
1701
+
1702
+ handle.position.copy( this.worldPosition );
1703
+ handle.visible = this.dragging;
1704
+
1705
+ } else if ( handle.name === 'DELTA' ) {
1706
+
1707
+ handle.position.copy( this.worldPositionStart );
1708
+ handle.quaternion.copy( this.worldQuaternionStart );
1709
+ _tempVector.set( 1e-10, 1e-10, 1e-10 ).add( this.worldPositionStart ).sub( this.worldPosition ).multiplyScalar( - 1 );
1710
+ _tempVector.applyQuaternion( this.worldQuaternionStart.clone().invert() );
1711
+ handle.scale.copy( _tempVector );
1712
+ handle.visible = this.dragging;
1713
+
1714
+ } else {
1715
+
1716
+ handle.quaternion.copy( quaternion );
1717
+
1718
+ if ( this.dragging ) {
1719
+
1720
+ handle.position.copy( this.worldPositionStart );
1721
+
1722
+ } else {
1723
+
1724
+ handle.position.copy( this.worldPosition );
1725
+
1726
+ }
1727
+
1728
+ if ( this.axis ) {
1729
+
1730
+ handle.visible = this.axis.search( handle.name ) !== - 1;
1731
+
1732
+ }
1733
+
1734
+ }
1735
+
1736
+ // If updating helper, skip rest of the loop
1737
+ continue;
1738
+
1739
+ }
1740
+
1741
+ // Align handles to current local or world rotation
1742
+
1743
+ handle.quaternion.copy( quaternion );
1744
+
1745
+ if ( this.mode === 'translate' || this.mode === 'scale' ) {
1746
+
1747
+ // Hide translate and scale axis facing the camera
1748
+
1749
+ const AXIS_HIDE_THRESHOLD = 0.99;
1750
+ const PLANE_HIDE_THRESHOLD = 0.2;
1751
+
1752
+ if ( handle.name === 'X' ) {
1753
+
1754
+ if ( Math.abs( _alignVector.copy( _unitX ).applyQuaternion( quaternion ).dot( this.eye ) ) > AXIS_HIDE_THRESHOLD ) {
1755
+
1756
+ handle.scale.set( 1e-10, 1e-10, 1e-10 );
1757
+ handle.visible = false;
1758
+
1759
+ }
1760
+
1761
+ }
1762
+
1763
+ if ( handle.name === 'Y' ) {
1764
+
1765
+ if ( Math.abs( _alignVector.copy( _unitY ).applyQuaternion( quaternion ).dot( this.eye ) ) > AXIS_HIDE_THRESHOLD ) {
1766
+
1767
+ handle.scale.set( 1e-10, 1e-10, 1e-10 );
1768
+ handle.visible = false;
1769
+
1770
+ }
1771
+
1772
+ }
1773
+
1774
+ if ( handle.name === 'Z' ) {
1775
+
1776
+ if ( Math.abs( _alignVector.copy( _unitZ ).applyQuaternion( quaternion ).dot( this.eye ) ) > AXIS_HIDE_THRESHOLD ) {
1777
+
1778
+ handle.scale.set( 1e-10, 1e-10, 1e-10 );
1779
+ handle.visible = false;
1780
+
1781
+ }
1782
+
1783
+ }
1784
+
1785
+ if ( handle.name === 'XY' ) {
1786
+
1787
+ if ( Math.abs( _alignVector.copy( _unitZ ).applyQuaternion( quaternion ).dot( this.eye ) ) < PLANE_HIDE_THRESHOLD ) {
1788
+
1789
+ handle.scale.set( 1e-10, 1e-10, 1e-10 );
1790
+ handle.visible = false;
1791
+
1792
+ }
1793
+
1794
+ }
1795
+
1796
+ if ( handle.name === 'YZ' ) {
1797
+
1798
+ if ( Math.abs( _alignVector.copy( _unitX ).applyQuaternion( quaternion ).dot( this.eye ) ) < PLANE_HIDE_THRESHOLD ) {
1799
+
1800
+ handle.scale.set( 1e-10, 1e-10, 1e-10 );
1801
+ handle.visible = false;
1802
+
1803
+ }
1804
+
1805
+ }
1806
+
1807
+ if ( handle.name === 'XZ' ) {
1808
+
1809
+ if ( Math.abs( _alignVector.copy( _unitY ).applyQuaternion( quaternion ).dot( this.eye ) ) < PLANE_HIDE_THRESHOLD ) {
1810
+
1811
+ handle.scale.set( 1e-10, 1e-10, 1e-10 );
1812
+ handle.visible = false;
1813
+
1814
+ }
1815
+
1816
+ }
1817
+
1818
+ } else if ( this.mode === 'rotate' ) {
1819
+
1820
+ // Align handles to current local or world rotation
1821
+
1822
+ _tempQuaternion2.copy( quaternion );
1823
+ _alignVector.copy( this.eye ).applyQuaternion( _tempQuaternion.copy( quaternion ).invert() );
1824
+
1825
+ if ( handle.name.search( 'E' ) !== - 1 ) {
1826
+
1827
+ handle.quaternion.setFromRotationMatrix( _lookAtMatrix.lookAt( this.eye, _zeroVector, _unitY ) );
1828
+
1829
+ }
1830
+
1831
+ if ( handle.name === 'X' ) {
1832
+
1833
+ _tempQuaternion.setFromAxisAngle( _unitX, Math.atan2( - _alignVector.y, _alignVector.z ) );
1834
+ _tempQuaternion.multiplyQuaternions( _tempQuaternion2, _tempQuaternion );
1835
+ handle.quaternion.copy( _tempQuaternion );
1836
+
1837
+ }
1838
+
1839
+ if ( handle.name === 'Y' ) {
1840
+
1841
+ _tempQuaternion.setFromAxisAngle( _unitY, Math.atan2( _alignVector.x, _alignVector.z ) );
1842
+ _tempQuaternion.multiplyQuaternions( _tempQuaternion2, _tempQuaternion );
1843
+ handle.quaternion.copy( _tempQuaternion );
1844
+
1845
+ }
1846
+
1847
+ if ( handle.name === 'Z' ) {
1848
+
1849
+ _tempQuaternion.setFromAxisAngle( _unitZ, Math.atan2( _alignVector.y, _alignVector.x ) );
1850
+ _tempQuaternion.multiplyQuaternions( _tempQuaternion2, _tempQuaternion );
1851
+ handle.quaternion.copy( _tempQuaternion );
1852
+
1853
+ }
1854
+
1855
+ }
1856
+
1857
+ // Hide disabled axes
1858
+ handle.visible = handle.visible && ( handle.name.indexOf( 'X' ) === - 1 || this.showX );
1859
+ handle.visible = handle.visible && ( handle.name.indexOf( 'Y' ) === - 1 || this.showY );
1860
+ handle.visible = handle.visible && ( handle.name.indexOf( 'Z' ) === - 1 || this.showZ );
1861
+ handle.visible = handle.visible && ( handle.name.indexOf( 'E' ) === - 1 || ( this.showX && this.showY && this.showZ ) );
1862
+
1863
+ // Hide disabled plane helpers
1864
+ handle.visible = handle.visible && ( handle.name.indexOf( 'XY' ) === - 1 || this.showXY );
1865
+ handle.visible = handle.visible && ( handle.name.indexOf( 'YZ' ) === - 1 || this.showYZ );
1866
+ handle.visible = handle.visible && ( handle.name.indexOf( 'XZ' ) === - 1 || this.showXZ );
1867
+
1868
+ // Hide disabled rotation helpers
1869
+ handle.visible = handle.visible && ( handle.name !== 'E' || this.showE );
1870
+ handle.visible = handle.visible && ( handle.name !== 'XYZE' || this.showXYZE );
1871
+
1872
+ // highlight selected axis
1873
+
1874
+ handle.material._color = handle.material._color || handle.material.color.clone();
1875
+ handle.material._opacity = handle.material._opacity || handle.material.opacity;
1876
+
1877
+ handle.material.color.copy( handle.material._color );
1878
+ handle.material.opacity = handle.material._opacity;
1879
+
1880
+ if ( this.enabled && this.axis ) {
1881
+
1882
+ if ( handle.name === this.axis ) {
1883
+
1884
+ handle.material.color.copy( this.materialLib.active.color );
1885
+ handle.material.opacity = 1.0;
1886
+
1887
+ } else if ( this.axis.split( '' ).some( function ( a ) {
1888
+
1889
+ return handle.name === a;
1890
+
1891
+ } ) ) {
1892
+
1893
+ handle.material.color.copy( this.materialLib.active.color );
1894
+ handle.material.opacity = 1.0;
1895
+
1896
+ }
1897
+
1898
+ }
1899
+
1900
+ }
1901
+
1902
+ super.updateMatrixWorld( force );
1903
+
1904
+ }
1905
+
1906
+ }
1907
+
1908
+ //
1909
+
1910
+ class TransformControlsPlane extends Mesh {
1911
+
1912
+ constructor() {
1913
+
1914
+ super(
1915
+ new PlaneGeometry( 100000, 100000, 2, 2 ),
1916
+ new MeshBasicMaterial( { visible: false, wireframe: true, side: DoubleSide, transparent: true, opacity: 0.1, toneMapped: false } )
1917
+ );
1918
+
1919
+ this.isTransformControlsPlane = true;
1920
+
1921
+ this.type = 'TransformControlsPlane';
1922
+
1923
+ }
1924
+
1925
+ updateMatrixWorld( force ) {
1926
+
1927
+ let space = this.space;
1928
+
1929
+ this.position.copy( this.worldPosition );
1930
+
1931
+ if ( this.mode === 'scale' ) space = 'local'; // scale always oriented to local rotation
1932
+
1933
+ _v1.copy( _unitX ).applyQuaternion( space === 'local' ? this.worldQuaternion : _identityQuaternion );
1934
+ _v2.copy( _unitY ).applyQuaternion( space === 'local' ? this.worldQuaternion : _identityQuaternion );
1935
+ _v3.copy( _unitZ ).applyQuaternion( space === 'local' ? this.worldQuaternion : _identityQuaternion );
1936
+
1937
+ // Align the plane for current transform mode, axis and space.
1938
+
1939
+ _alignVector.copy( _v2 );
1940
+
1941
+ switch ( this.mode ) {
1942
+
1943
+ case 'translate':
1944
+ case 'scale':
1945
+ switch ( this.axis ) {
1946
+
1947
+ case 'X':
1948
+ _alignVector.copy( this.eye ).cross( _v1 );
1949
+ _dirVector.copy( _v1 ).cross( _alignVector );
1950
+ break;
1951
+ case 'Y':
1952
+ _alignVector.copy( this.eye ).cross( _v2 );
1953
+ _dirVector.copy( _v2 ).cross( _alignVector );
1954
+ break;
1955
+ case 'Z':
1956
+ _alignVector.copy( this.eye ).cross( _v3 );
1957
+ _dirVector.copy( _v3 ).cross( _alignVector );
1958
+ break;
1959
+ case 'XY':
1960
+ _dirVector.copy( _v3 );
1961
+ break;
1962
+ case 'YZ':
1963
+ _dirVector.copy( _v1 );
1964
+ break;
1965
+ case 'XZ':
1966
+ _alignVector.copy( _v3 );
1967
+ _dirVector.copy( _v2 );
1968
+ break;
1969
+ case 'XYZ':
1970
+ case 'E':
1971
+ _dirVector.set( 0, 0, 0 );
1972
+ break;
1973
+
1974
+ }
1975
+
1976
+ break;
1977
+ case 'rotate':
1978
+ default:
1979
+ // special case for rotate
1980
+ _dirVector.set( 0, 0, 0 );
1981
+
1982
+ }
1983
+
1984
+ if ( _dirVector.length() === 0 ) {
1985
+
1986
+ // If in rotate mode, make the plane parallel to camera
1987
+ this.quaternion.copy( this.cameraQuaternion );
1988
+
1989
+ } else {
1990
+
1991
+ _tempMatrix.lookAt( _tempVector.set( 0, 0, 0 ), _dirVector, _alignVector );
1992
+
1993
+ this.quaternion.setFromRotationMatrix( _tempMatrix );
1994
+
1995
+ }
1996
+
1997
+ super.updateMatrixWorld( force );
1998
+
1999
+ }
2000
+
2001
+ }
2002
+
2003
+ export { TransformControls, TransformControlsGizmo, TransformControlsPlane };