super-three 0.133.3 → 0.136.0

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 (354) hide show
  1. package/build/three.js +1059 -783
  2. package/build/three.min.js +1 -1
  3. package/build/three.module.js +1424 -895
  4. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
  5. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
  6. package/examples/fonts/open-sans/open-sans.css +9 -0
  7. package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
  8. package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +3966 -0
  9. package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
  10. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
  11. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
  12. package/examples/fonts/tabler-icons/tabler-icons.min.css +4 -0
  13. package/examples/js/animation/CCDIKSolver.js +0 -1
  14. package/examples/js/animation/MMDPhysics.js +1 -3
  15. package/examples/js/controls/ArcballControls.js +99 -72
  16. package/examples/js/controls/DragControls.js +7 -0
  17. package/examples/js/controls/OrbitControls.js +5 -36
  18. package/examples/js/controls/TrackballControls.js +3 -2
  19. package/examples/js/controls/TransformControls.js +24 -1
  20. package/examples/js/csm/CSM.js +2 -2
  21. package/examples/js/csm/CSMFrustum.js +133 -0
  22. package/examples/js/curves/CurveExtras.js +0 -2
  23. package/examples/js/effects/AsciiEffect.js +2 -9
  24. package/examples/js/exporters/GLTFExporter.js +148 -64
  25. package/examples/js/exporters/USDZExporter.js +45 -26
  26. package/examples/js/geometries/TeapotGeometry.js +0 -1
  27. package/examples/js/interactive/SelectionBox.js +2 -0
  28. package/examples/js/interactive/SelectionHelper.js +22 -7
  29. package/examples/js/lights/RectAreaLightUniformsLib.js +4 -0
  30. package/examples/js/lines/LineMaterial.js +58 -20
  31. package/examples/js/lines/LineSegments2.js +29 -24
  32. package/examples/js/loaders/3DMLoader.js +24 -11
  33. package/examples/js/loaders/3MFLoader.js +2 -2
  34. package/examples/js/loaders/AMFLoader.js +0 -2
  35. package/examples/js/loaders/ColladaLoader.js +61 -4
  36. package/examples/js/loaders/EXRLoader.js +185 -262
  37. package/examples/js/loaders/FBXLoader.js +4 -5
  38. package/examples/js/loaders/GLTFLoader.js +96 -33
  39. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -8
  40. package/examples/js/loaders/KTX2Loader.js +23 -2
  41. package/examples/js/loaders/KTXLoader.js +1 -1
  42. package/examples/js/loaders/LDrawLoader.js +26 -30
  43. package/examples/js/loaders/LUT3dlLoader.js +2 -0
  44. package/examples/js/loaders/LUTCubeLoader.js +2 -0
  45. package/examples/js/loaders/LWOLoader.js +8 -6
  46. package/examples/js/loaders/LogLuvLoader.js +766 -0
  47. package/examples/js/loaders/MMDLoader.js +0 -1
  48. package/examples/js/loaders/NRRDLoader.js +9 -2
  49. package/examples/js/loaders/OBJLoader.js +0 -2
  50. package/examples/js/loaders/PLYLoader.js +33 -8
  51. package/examples/js/loaders/RGBELoader.js +2 -16
  52. package/examples/js/loaders/RGBMLoader.js +55 -5
  53. package/examples/js/loaders/SVGLoader.js +9 -5
  54. package/examples/js/loaders/TDSLoader.js +237 -271
  55. package/examples/js/loaders/VOXLoader.js +1 -0
  56. package/examples/js/loaders/VRMLLoader.js +2 -1
  57. package/examples/js/loaders/lwo/LWO2Parser.js +1 -0
  58. package/examples/js/loaders/lwo/LWO3Parser.js +4 -2
  59. package/examples/js/math/ImprovedNoise.js +1 -1
  60. package/examples/js/misc/GPUComputationRenderer.js +3 -1
  61. package/examples/js/objects/Lensflare.js +2 -10
  62. package/examples/js/objects/MarchingCubes.js +42 -128
  63. package/examples/js/objects/Reflector.js +7 -0
  64. package/examples/js/objects/Refractor.js +7 -0
  65. package/examples/js/objects/Sky.js +1 -1
  66. package/examples/js/objects/Water.js +2 -2
  67. package/examples/js/objects/Water2.js +4 -7
  68. package/examples/js/postprocessing/GlitchPass.js +3 -1
  69. package/examples/js/postprocessing/SSAOPass.js +1 -0
  70. package/examples/js/renderers/CSS2DRenderer.js +4 -4
  71. package/examples/js/renderers/CSS3DRenderer.js +4 -4
  72. package/examples/js/shaders/ConvolutionShader.js +0 -1
  73. package/examples/js/shaders/FXAAShader.js +1 -1
  74. package/examples/js/shaders/FilmShader.js +1 -1
  75. package/examples/js/shaders/GammaCorrectionShader.js +1 -1
  76. package/examples/js/shaders/HorizontalBlurShader.js +1 -2
  77. package/examples/js/shaders/SSRShader.js +1 -1
  78. package/examples/js/shaders/SSRrShader.js +1 -1
  79. package/examples/js/shaders/VerticalBlurShader.js +1 -2
  80. package/examples/js/utils/GeometryUtils.js +1 -1
  81. package/examples/js/utils/RoughnessMipmapper.js +18 -28
  82. package/examples/jsm/animation/CCDIKSolver.js +0 -1
  83. package/examples/jsm/animation/MMDPhysics.js +0 -2
  84. package/examples/jsm/controls/ArcballControls.js +80 -77
  85. package/examples/jsm/controls/DragControls.js +7 -0
  86. package/examples/jsm/controls/OrbitControls.js +9 -51
  87. package/examples/jsm/controls/TrackballControls.js +1 -1
  88. package/examples/jsm/controls/TransformControls.js +24 -1
  89. package/examples/jsm/csm/CSM.js +3 -3
  90. package/examples/jsm/csm/{Frustum.js → CSMFrustum.js} +3 -3
  91. package/examples/jsm/curves/CurveExtras.js +0 -2
  92. package/examples/jsm/effects/AsciiEffect.js +2 -9
  93. package/examples/jsm/exporters/GLTFExporter.js +161 -75
  94. package/examples/jsm/exporters/USDZExporter.js +47 -26
  95. package/examples/jsm/geometries/TeapotGeometry.js +0 -1
  96. package/examples/jsm/interactive/SelectionBox.js +1 -0
  97. package/examples/jsm/interactive/SelectionHelper.js +19 -7
  98. package/examples/jsm/libs/flow.module.js +3338 -0
  99. package/examples/jsm/libs/lil-gui.module.min.js +8 -0
  100. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  101. package/examples/jsm/lights/RectAreaLightUniformsLib.js +7 -0
  102. package/examples/jsm/lines/LineMaterial.js +59 -23
  103. package/examples/jsm/lines/LineSegments2.js +22 -18
  104. package/examples/jsm/loaders/3DMLoader.js +18 -12
  105. package/examples/jsm/loaders/3MFLoader.js +2 -2
  106. package/examples/jsm/loaders/AMFLoader.js +0 -2
  107. package/examples/jsm/loaders/ColladaLoader.js +61 -4
  108. package/examples/jsm/loaders/EXRLoader.js +184 -293
  109. package/examples/jsm/loaders/FBXLoader.js +4 -5
  110. package/examples/jsm/loaders/GLTFLoader.js +101 -37
  111. package/examples/jsm/loaders/HDRCubeTextureLoader.js +1 -14
  112. package/examples/jsm/loaders/KTX2Loader.js +30 -2
  113. package/examples/jsm/loaders/KTXLoader.js +1 -1
  114. package/examples/jsm/loaders/LDrawLoader.js +23 -24
  115. package/examples/jsm/loaders/LUT3dlLoader.js +2 -0
  116. package/examples/jsm/loaders/LUTCubeLoader.js +2 -0
  117. package/examples/jsm/loaders/LWOLoader.js +8 -6
  118. package/examples/jsm/loaders/LogLuvLoader.js +606 -0
  119. package/examples/jsm/loaders/MMDLoader.js +0 -1
  120. package/examples/jsm/loaders/NRRDLoader.js +10 -2
  121. package/examples/jsm/loaders/OBJLoader.js +0 -2
  122. package/examples/jsm/loaders/PLYLoader.js +34 -8
  123. package/examples/jsm/loaders/RGBELoader.js +0 -20
  124. package/examples/jsm/loaders/RGBMLoader.js +61 -7
  125. package/examples/jsm/loaders/SVGLoader.js +9 -6
  126. package/examples/jsm/loaders/TDSLoader.js +236 -275
  127. package/examples/jsm/loaders/VOXLoader.js +1 -0
  128. package/examples/jsm/loaders/VRMLLoader.js +2 -1
  129. package/examples/jsm/loaders/lwo/LWO2Parser.js +1 -0
  130. package/examples/jsm/loaders/lwo/LWO3Parser.js +2 -2
  131. package/examples/jsm/math/ImprovedNoise.js +1 -1
  132. package/examples/jsm/misc/GPUComputationRenderer.js +3 -1
  133. package/examples/jsm/node-editor/NodeEditor.js +456 -0
  134. package/examples/jsm/node-editor/accessors/NormalEditor.js +30 -0
  135. package/examples/jsm/node-editor/accessors/PositionEditor.js +30 -0
  136. package/examples/jsm/node-editor/accessors/UVEditor.js +26 -0
  137. package/examples/jsm/node-editor/display/BlendEditor.js +43 -0
  138. package/examples/jsm/node-editor/examples/animate-uv.json +1 -0
  139. package/examples/jsm/node-editor/examples/fake-top-light.json +1 -0
  140. package/examples/jsm/node-editor/examples/oscillator-color.json +1 -0
  141. package/examples/jsm/node-editor/examples/rim.json +1 -0
  142. package/examples/jsm/node-editor/inputs/ColorEditor.js +91 -0
  143. package/examples/jsm/node-editor/inputs/FloatEditor.js +24 -0
  144. package/examples/jsm/node-editor/inputs/SliderEditor.js +68 -0
  145. package/examples/jsm/node-editor/inputs/Vector2Editor.js +28 -0
  146. package/examples/jsm/node-editor/inputs/Vector3Editor.js +30 -0
  147. package/examples/jsm/node-editor/inputs/Vector4Editor.js +37 -0
  148. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +108 -0
  149. package/examples/jsm/node-editor/math/DotEditor.js +36 -0
  150. package/examples/jsm/node-editor/math/InvertEditor.js +38 -0
  151. package/examples/jsm/node-editor/math/LimiterEditor.js +48 -0
  152. package/examples/jsm/node-editor/math/NormalizeEditor.js +26 -0
  153. package/examples/jsm/node-editor/math/OperatorEditor.js +50 -0
  154. package/examples/jsm/node-editor/math/PowerEditor.js +34 -0
  155. package/examples/jsm/node-editor/math/TrigonometryEditor.js +39 -0
  156. package/examples/jsm/node-editor/procedural/CheckerEditor.js +26 -0
  157. package/examples/jsm/node-editor/utils/OscillatorEditor.js +42 -0
  158. package/examples/jsm/node-editor/utils/TimerEditor.js +57 -0
  159. package/examples/jsm/nodes/core/NodeBuilder.js +2 -2
  160. package/examples/jsm/nodes/materials/StandardNodeMaterial.js +1 -1
  161. package/examples/jsm/nodes/materials/nodes/StandardNode.js +7 -6
  162. package/examples/jsm/nodes/math/MathNode.js +12 -0
  163. package/examples/jsm/nodes/misc/BumpMapNode.js +1 -1
  164. package/examples/jsm/nodes/misc/TextureCubeUVNode.js +1 -4
  165. package/examples/jsm/nodes/utils/ColorSpaceNode.js +1 -164
  166. package/examples/jsm/objects/Lensflare.js +3 -14
  167. package/examples/jsm/objects/MarchingCubes.js +46 -152
  168. package/examples/jsm/objects/Reflector.js +7 -0
  169. package/examples/jsm/objects/Refractor.js +7 -0
  170. package/examples/jsm/objects/Sky.js +1 -1
  171. package/examples/jsm/objects/Water.js +2 -2
  172. package/examples/jsm/objects/Water2.js +4 -8
  173. package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +1 -1
  174. package/examples/jsm/postprocessing/AfterimagePass.js +1 -1
  175. package/examples/jsm/postprocessing/BloomPass.js +1 -1
  176. package/examples/jsm/postprocessing/BokehPass.js +1 -1
  177. package/examples/jsm/postprocessing/ClearPass.js +1 -1
  178. package/examples/jsm/postprocessing/CubeTexturePass.js +1 -1
  179. package/examples/jsm/postprocessing/DotScreenPass.js +1 -1
  180. package/examples/jsm/postprocessing/EffectComposer.js +3 -3
  181. package/examples/jsm/postprocessing/FilmPass.js +1 -1
  182. package/examples/jsm/postprocessing/GlitchPass.js +4 -2
  183. package/examples/jsm/postprocessing/HalftonePass.js +1 -1
  184. package/examples/jsm/postprocessing/MaskPass.js +1 -1
  185. package/examples/jsm/postprocessing/OutlinePass.js +1 -1
  186. package/examples/jsm/postprocessing/RenderPass.js +1 -1
  187. package/examples/jsm/postprocessing/SAOPass.js +2 -2
  188. package/examples/jsm/postprocessing/SMAAPass.js +1 -1
  189. package/examples/jsm/postprocessing/SSAARenderPass.js +1 -1
  190. package/examples/jsm/postprocessing/SSAOPass.js +2 -1
  191. package/examples/jsm/postprocessing/SSRPass.js +1 -1
  192. package/examples/jsm/postprocessing/SSRrPass.js +1 -1
  193. package/examples/jsm/postprocessing/SavePass.js +1 -1
  194. package/examples/jsm/postprocessing/ShaderPass.js +1 -1
  195. package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
  196. package/examples/jsm/postprocessing/TexturePass.js +1 -1
  197. package/examples/jsm/postprocessing/UnrealBloomPass.js +1 -1
  198. package/examples/jsm/renderers/CSS2DRenderer.js +5 -4
  199. package/examples/jsm/renderers/CSS3DRenderer.js +5 -4
  200. package/examples/jsm/renderers/nodes/Nodes.js +15 -13
  201. package/examples/jsm/renderers/nodes/ShaderNode.js +194 -41
  202. package/examples/jsm/renderers/nodes/accessors/MaterialNode.js +6 -6
  203. package/examples/jsm/renderers/nodes/accessors/ModelViewProjectionNode.js +5 -5
  204. package/examples/jsm/renderers/nodes/accessors/NormalNode.js +14 -3
  205. package/examples/jsm/renderers/nodes/accessors/PointUVNode.js +3 -3
  206. package/examples/jsm/renderers/nodes/accessors/PositionNode.js +15 -5
  207. package/examples/jsm/renderers/nodes/accessors/SkinningNode.js +107 -0
  208. package/examples/jsm/renderers/nodes/accessors/UVNode.js +7 -5
  209. package/examples/jsm/renderers/nodes/core/ArrayInputNode.js +3 -3
  210. package/examples/jsm/renderers/nodes/core/AttributeNode.js +6 -0
  211. package/examples/jsm/renderers/nodes/core/BypassNode.js +38 -0
  212. package/examples/jsm/renderers/nodes/core/CodeNode.js +3 -3
  213. package/examples/jsm/renderers/nodes/core/ContextNode.js +4 -19
  214. package/examples/jsm/renderers/nodes/core/ExpressionNode.js +13 -2
  215. package/examples/jsm/renderers/nodes/core/FunctionNode.js +19 -132
  216. package/examples/jsm/renderers/nodes/core/InputNode.js +13 -3
  217. package/examples/jsm/renderers/nodes/core/Node.js +32 -10
  218. package/examples/jsm/renderers/nodes/core/NodeBuilder.js +146 -128
  219. package/examples/jsm/renderers/nodes/core/NodeFunction.js +22 -0
  220. package/examples/jsm/renderers/nodes/core/NodeFunctionInput.js +4 -4
  221. package/examples/jsm/renderers/nodes/core/NodeKeywords.js +18 -179
  222. package/examples/jsm/renderers/nodes/core/NodeParser.js +11 -0
  223. package/examples/jsm/renderers/nodes/core/NodeVar.js +2 -2
  224. package/examples/jsm/renderers/nodes/core/PropertyNode.js +14 -2
  225. package/examples/jsm/renderers/nodes/core/TempNode.js +10 -13
  226. package/examples/jsm/renderers/nodes/core/VarNode.js +12 -7
  227. package/examples/jsm/renderers/nodes/core/VaryNode.js +23 -8
  228. package/examples/jsm/renderers/nodes/core/constants.js +2 -0
  229. package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +60 -43
  230. package/examples/jsm/renderers/nodes/display/NormalMapNode.js +21 -22
  231. package/examples/jsm/renderers/nodes/functions/BSDFs.js +64 -101
  232. package/examples/jsm/renderers/nodes/functions/PhysicalMaterialFunctions.js +27 -0
  233. package/examples/jsm/renderers/nodes/inputs/BufferNode.js +25 -0
  234. package/examples/jsm/renderers/nodes/inputs/IntNode.js +17 -0
  235. package/examples/jsm/renderers/nodes/inputs/TextureNode.js +10 -2
  236. package/examples/jsm/renderers/nodes/lights/LightContextNode.js +20 -14
  237. package/examples/jsm/renderers/nodes/lights/LightNode.js +32 -36
  238. package/examples/jsm/renderers/nodes/math/CondNode.js +60 -0
  239. package/examples/jsm/renderers/nodes/math/MathNode.js +90 -37
  240. package/examples/jsm/renderers/nodes/math/OperatorNode.js +124 -31
  241. package/examples/jsm/renderers/nodes/parsers/GLSLNodeFunction.js +137 -0
  242. package/examples/jsm/renderers/nodes/parsers/GLSLNodeParser.js +14 -0
  243. package/examples/jsm/renderers/nodes/parsers/WGSLNodeFunction.js +89 -0
  244. package/examples/jsm/renderers/nodes/parsers/WGSLNodeParser.js +14 -0
  245. package/examples/jsm/renderers/nodes/procedural/CheckerNode.js +7 -9
  246. package/examples/jsm/renderers/nodes/utils/ArrayElementNode.js +31 -0
  247. package/examples/jsm/renderers/nodes/utils/ConvertNode.js +33 -0
  248. package/examples/jsm/renderers/nodes/utils/JoinNode.js +7 -7
  249. package/examples/jsm/renderers/nodes/utils/OscNode.js +58 -0
  250. package/examples/jsm/renderers/nodes/utils/SplitNode.js +18 -8
  251. package/examples/jsm/renderers/nodes/utils/SpriteSheetUVNode.js +7 -7
  252. package/examples/jsm/renderers/nodes/utils/TimerNode.js +1 -1
  253. package/examples/jsm/renderers/webgl/nodes/SlotNode.js +22 -0
  254. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +192 -95
  255. package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +2 -2
  256. package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +2 -2
  257. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +1 -1
  258. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +10 -9
  259. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +2 -4
  260. package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +2 -4
  261. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +15 -23
  262. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +44 -65
  263. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +12 -28
  264. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +61 -28
  265. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +34 -27
  266. package/examples/jsm/renderers/webgpu/constants.js +2 -2
  267. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +453 -95
  268. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
  269. package/examples/jsm/shaders/ConvolutionShader.js +0 -1
  270. package/examples/jsm/shaders/FXAAShader.js +1 -1
  271. package/examples/jsm/shaders/FilmShader.js +1 -1
  272. package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
  273. package/examples/jsm/shaders/HorizontalBlurShader.js +1 -2
  274. package/examples/jsm/shaders/SSRShader.js +1 -1
  275. package/examples/jsm/shaders/SSRrShader.js +1 -1
  276. package/examples/jsm/shaders/VerticalBlurShader.js +1 -2
  277. package/examples/jsm/utils/GeometryUtils.js +1 -1
  278. package/examples/jsm/utils/RoughnessMipmapper.js +19 -31
  279. package/examples/jsm/utils/WorkerPool.js +11 -11
  280. package/examples/jsm/webxr/OculusHandPointerModel.js +6 -6
  281. package/package.json +24 -18
  282. package/src/Three.Legacy.js +18 -0
  283. package/src/Three.js +1 -3
  284. package/src/cameras/StereoCamera.js +8 -7
  285. package/src/constants.js +1 -8
  286. package/src/core/Layers.js +7 -1
  287. package/src/core/Object3D.js +3 -1
  288. package/src/extras/PMREMGenerator.js +23 -109
  289. package/src/extras/core/Interpolations.js +1 -1
  290. package/src/geometries/LatheGeometry.js +70 -47
  291. package/src/helpers/CameraHelper.js +1 -1
  292. package/src/loaders/FileLoader.js +98 -144
  293. package/src/loaders/ImageLoader.js +9 -4
  294. package/src/loaders/LoaderUtils.js +26 -0
  295. package/src/loaders/MaterialLoader.js +7 -4
  296. package/src/loaders/ObjectLoader.js +2 -0
  297. package/src/materials/Material.js +4 -4
  298. package/src/materials/MeshPhysicalMaterial.js +20 -14
  299. package/src/math/Color.js +0 -38
  300. package/src/math/MathUtils.js +5 -16
  301. package/src/math/Ray.js +2 -2
  302. package/src/math/Sphere.js +10 -1
  303. package/src/objects/Skeleton.js +1 -0
  304. package/src/renderers/WebGLMultisampleRenderTarget.js +7 -1
  305. package/src/renderers/WebGLRenderer.js +105 -132
  306. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +2 -2
  307. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +1 -1
  308. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +2 -24
  309. package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -74
  310. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
  311. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +1 -1
  312. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +19 -6
  313. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +28 -2
  314. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
  315. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
  316. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +1 -1
  317. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +23 -5
  318. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +2 -1
  319. package/src/renderers/shaders/ShaderLib.js +6 -4
  320. package/src/renderers/shaders/UniformsLib.js +1 -2
  321. package/src/renderers/webgl/WebGLCapabilities.js +0 -2
  322. package/src/renderers/webgl/WebGLExtensions.js +1 -0
  323. package/src/renderers/webgl/WebGLMaterials.js +27 -15
  324. package/src/renderers/webgl/WebGLMorphtargets.js +1 -0
  325. package/src/renderers/webgl/WebGLProgram.js +11 -24
  326. package/src/renderers/webgl/WebGLPrograms.js +194 -33
  327. package/src/renderers/webgl/WebGLRenderLists.js +4 -14
  328. package/src/renderers/webgl/WebGLShaderCache.js +120 -0
  329. package/src/renderers/webgl/WebGLShadowMap.js +14 -5
  330. package/src/renderers/webgl/WebGLState.js +76 -17
  331. package/src/renderers/webgl/WebGLTextures.js +367 -61
  332. package/src/renderers/webgl/WebGLUniforms.js +45 -1
  333. package/src/renderers/webxr/WebXRManager.js +77 -109
  334. package/src/scenes/Scene.js +1 -1
  335. package/src/textures/DataTexture.js +0 -2
  336. package/src/textures/DataTexture2DArray.js +0 -2
  337. package/src/textures/DataTexture3D.js +0 -2
  338. package/src/textures/FramebufferTexture.js +25 -0
  339. package/src/textures/Texture.js +6 -0
  340. package/examples/js/controls/DeviceOrientationControls.js +0 -147
  341. package/examples/js/libs/dat.gui.min.js +0 -14
  342. package/examples/jsm/controls/DeviceOrientationControls.js +0 -153
  343. package/examples/jsm/libs/dat.gui.module.js +0 -3575
  344. package/examples/jsm/libs/glslang.js +0 -78
  345. package/examples/jsm/libs/glslang.wasm +0 -0
  346. package/examples/jsm/renderers/nodes/consts/MathConsts.js +0 -7
  347. package/examples/jsm/renderers/nodes/core/ConstNode.js +0 -39
  348. package/examples/jsm/renderers/nodes/core/NodeSlot.js +0 -13
  349. package/examples/jsm/renderers/nodes/core/StructNode.js +0 -80
  350. package/examples/jsm/renderers/nodes/core/StructVarNode.js +0 -75
  351. package/examples/jsm/renderers/nodes/functions/EncodingFunctions.js +0 -99
  352. package/examples/jsm/renderers/nodes/functions/MathFunctions.js +0 -47
  353. package/examples/jsm/renderers/webgpu/nodes/ShaderLib.js +0 -152
  354. package/src/extras/objects/ImmediateRenderObject.js +0 -31
@@ -1,3575 +0,0 @@
1
- /**
2
- * dat-gui JavaScript Controller Library
3
- * http://code.google.com/p/dat-gui
4
- *
5
- * Copyright 2011 Data Arts Team, Google Creative Lab
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- */
13
-
14
- function ___$insertStyle( css ) {
15
-
16
- if ( ! css ) {
17
-
18
- return;
19
-
20
- }
21
- if ( typeof window === 'undefined' ) {
22
-
23
- return;
24
-
25
- }
26
-
27
- var style = document.createElement( 'style' );
28
-
29
- style.setAttribute( 'type', 'text/css' );
30
- style.innerHTML = css;
31
- document.head.appendChild( style );
32
-
33
- return css;
34
-
35
- }
36
-
37
- function colorToString( color, forceCSSHex ) {
38
-
39
- var colorFormat = color.__state.conversionName.toString();
40
- var r = Math.round( color.r );
41
- var g = Math.round( color.g );
42
- var b = Math.round( color.b );
43
- var a = color.a;
44
- var h = Math.round( color.h );
45
- var s = color.s.toFixed( 1 );
46
- var v = color.v.toFixed( 1 );
47
- if ( forceCSSHex || colorFormat === 'THREE_CHAR_HEX' || colorFormat === 'SIX_CHAR_HEX' ) {
48
-
49
- var str = color.hex.toString( 16 );
50
- while ( str.length < 6 ) {
51
-
52
- str = '0' + str;
53
-
54
- }
55
- return '#' + str;
56
-
57
- } else if ( colorFormat === 'CSS_RGB' ) {
58
-
59
- return 'rgb(' + r + ',' + g + ',' + b + ')';
60
-
61
- } else if ( colorFormat === 'CSS_RGBA' ) {
62
-
63
- return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
64
-
65
- } else if ( colorFormat === 'HEX' ) {
66
-
67
- return '0x' + color.hex.toString( 16 );
68
-
69
- } else if ( colorFormat === 'RGB_ARRAY' ) {
70
-
71
- return '[' + r + ',' + g + ',' + b + ']';
72
-
73
- } else if ( colorFormat === 'RGBA_ARRAY' ) {
74
-
75
- return '[' + r + ',' + g + ',' + b + ',' + a + ']';
76
-
77
- } else if ( colorFormat === 'RGB_OBJ' ) {
78
-
79
- return '{r:' + r + ',g:' + g + ',b:' + b + '}';
80
-
81
- } else if ( colorFormat === 'RGBA_OBJ' ) {
82
-
83
- return '{r:' + r + ',g:' + g + ',b:' + b + ',a:' + a + '}';
84
-
85
- } else if ( colorFormat === 'HSV_OBJ' ) {
86
-
87
- return '{h:' + h + ',s:' + s + ',v:' + v + '}';
88
-
89
- } else if ( colorFormat === 'HSVA_OBJ' ) {
90
-
91
- return '{h:' + h + ',s:' + s + ',v:' + v + ',a:' + a + '}';
92
-
93
- }
94
- return 'unknown format';
95
-
96
- }
97
-
98
- var ARR_EACH = Array.prototype.forEach;
99
- var ARR_SLICE = Array.prototype.slice;
100
- var Common = {
101
- BREAK: {},
102
- extend: function extend( target ) {
103
-
104
- this.each( ARR_SLICE.call( arguments, 1 ), function ( obj ) {
105
-
106
- var keys = this.isObject( obj ) ? Object.keys( obj ) : [];
107
- keys.forEach( function ( key ) {
108
-
109
- if ( ! this.isUndefined( obj[ key ] ) ) {
110
-
111
- target[ key ] = obj[ key ];
112
-
113
- }
114
-
115
- }.bind( this ) );
116
-
117
- }, this );
118
- return target;
119
-
120
- },
121
- defaults: function defaults( target ) {
122
-
123
- this.each( ARR_SLICE.call( arguments, 1 ), function ( obj ) {
124
-
125
- var keys = this.isObject( obj ) ? Object.keys( obj ) : [];
126
- keys.forEach( function ( key ) {
127
-
128
- if ( this.isUndefined( target[ key ] ) ) {
129
-
130
- target[ key ] = obj[ key ];
131
-
132
- }
133
-
134
- }.bind( this ) );
135
-
136
- }, this );
137
- return target;
138
-
139
- },
140
- compose: function compose() {
141
-
142
- var toCall = ARR_SLICE.call( arguments );
143
- return function () {
144
-
145
- var args = ARR_SLICE.call( arguments );
146
- for ( var i = toCall.length - 1; i >= 0; i -- ) {
147
-
148
- args = [ toCall[ i ].apply( this, args ) ];
149
-
150
- }
151
- return args[ 0 ];
152
-
153
- };
154
-
155
- },
156
- each: function each( obj, itr, scope ) {
157
-
158
- if ( ! obj ) {
159
-
160
- return;
161
-
162
- }
163
- if ( ARR_EACH && obj.forEach && obj.forEach === ARR_EACH ) {
164
-
165
- obj.forEach( itr, scope );
166
-
167
- } else if ( obj.length === obj.length + 0 ) {
168
-
169
- var key = void 0;
170
- var l = void 0;
171
- for ( key = 0, l = obj.length; key < l; key ++ ) {
172
-
173
- if ( key in obj && itr.call( scope, obj[ key ], key ) === this.BREAK ) {
174
-
175
- return;
176
-
177
- }
178
-
179
- }
180
-
181
- } else {
182
-
183
- for ( var _key in obj ) {
184
-
185
- if ( itr.call( scope, obj[ _key ], _key ) === this.BREAK ) {
186
-
187
- return;
188
-
189
- }
190
-
191
- }
192
-
193
- }
194
-
195
- },
196
- defer: function defer( fnc ) {
197
-
198
- setTimeout( fnc, 0 );
199
-
200
- },
201
- debounce: function debounce( func, threshold, callImmediately ) {
202
-
203
- var timeout = void 0;
204
- return function () {
205
-
206
- var obj = this;
207
- var args = arguments;
208
- function delayed() {
209
-
210
- timeout = null;
211
- if ( ! callImmediately ) func.apply( obj, args );
212
-
213
- }
214
- var callNow = callImmediately || ! timeout;
215
- clearTimeout( timeout );
216
- timeout = setTimeout( delayed, threshold );
217
- if ( callNow ) {
218
-
219
- func.apply( obj, args );
220
-
221
- }
222
-
223
- };
224
-
225
- },
226
- toArray: function toArray( obj ) {
227
-
228
- if ( obj.toArray ) return obj.toArray();
229
- return ARR_SLICE.call( obj );
230
-
231
- },
232
- isUndefined: function isUndefined( obj ) {
233
-
234
- return obj === undefined;
235
-
236
- },
237
- isNull: function isNull( obj ) {
238
-
239
- return obj === null;
240
-
241
- },
242
- isNaN: function ( _isNaN ) {
243
-
244
- function isNaN() {
245
-
246
- return _isNaN.apply( this, arguments );
247
-
248
- }
249
- isNaN.toString = function () {
250
-
251
- return _isNaN.toString();
252
-
253
- };
254
- return isNaN;
255
-
256
- }( function ( obj ) {
257
-
258
- return isNaN( obj );
259
-
260
- } ),
261
- isArray: Array.isArray || function ( obj ) {
262
-
263
- return obj.constructor === Array;
264
-
265
- },
266
- isObject: function isObject( obj ) {
267
-
268
- return obj === Object( obj );
269
-
270
- },
271
- isNumber: function isNumber( obj ) {
272
-
273
- return obj === obj + 0;
274
-
275
- },
276
- isString: function isString( obj ) {
277
-
278
- return obj === obj + '';
279
-
280
- },
281
- isBoolean: function isBoolean( obj ) {
282
-
283
- return obj === false || obj === true;
284
-
285
- },
286
- isFunction: function isFunction( obj ) {
287
-
288
- return obj instanceof Function;
289
-
290
- }
291
- };
292
-
293
- var INTERPRETATIONS = [
294
- {
295
- litmus: Common.isString,
296
- conversions: {
297
- THREE_CHAR_HEX: {
298
- read: function read( original ) {
299
-
300
- var test = original.match( /^#([A-F0-9])([A-F0-9])([A-F0-9])$/i );
301
- if ( test === null ) {
302
-
303
- return false;
304
-
305
- }
306
- return {
307
- space: 'HEX',
308
- hex: parseInt( '0x' + test[ 1 ].toString() + test[ 1 ].toString() + test[ 2 ].toString() + test[ 2 ].toString() + test[ 3 ].toString() + test[ 3 ].toString(), 0 )
309
- };
310
-
311
- },
312
- write: colorToString
313
- },
314
- SIX_CHAR_HEX: {
315
- read: function read( original ) {
316
-
317
- var test = original.match( /^#([A-F0-9]{6})$/i );
318
- if ( test === null ) {
319
-
320
- return false;
321
-
322
- }
323
- return {
324
- space: 'HEX',
325
- hex: parseInt( '0x' + test[ 1 ].toString(), 0 )
326
- };
327
-
328
- },
329
- write: colorToString
330
- },
331
- CSS_RGB: {
332
- read: function read( original ) {
333
-
334
- var test = original.match( /^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/ );
335
- if ( test === null ) {
336
-
337
- return false;
338
-
339
- }
340
- return {
341
- space: 'RGB',
342
- r: parseFloat( test[ 1 ] ),
343
- g: parseFloat( test[ 2 ] ),
344
- b: parseFloat( test[ 3 ] )
345
- };
346
-
347
- },
348
- write: colorToString
349
- },
350
- CSS_RGBA: {
351
- read: function read( original ) {
352
-
353
- var test = original.match( /^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/ );
354
- if ( test === null ) {
355
-
356
- return false;
357
-
358
- }
359
- return {
360
- space: 'RGB',
361
- r: parseFloat( test[ 1 ] ),
362
- g: parseFloat( test[ 2 ] ),
363
- b: parseFloat( test[ 3 ] ),
364
- a: parseFloat( test[ 4 ] )
365
- };
366
-
367
- },
368
- write: colorToString
369
- }
370
- }
371
- },
372
- {
373
- litmus: Common.isNumber,
374
- conversions: {
375
- HEX: {
376
- read: function read( original ) {
377
-
378
- return {
379
- space: 'HEX',
380
- hex: original,
381
- conversionName: 'HEX'
382
- };
383
-
384
- },
385
- write: function write( color ) {
386
-
387
- return color.hex;
388
-
389
- }
390
- }
391
- }
392
- },
393
- {
394
- litmus: Common.isArray,
395
- conversions: {
396
- RGB_ARRAY: {
397
- read: function read( original ) {
398
-
399
- if ( original.length !== 3 ) {
400
-
401
- return false;
402
-
403
- }
404
- return {
405
- space: 'RGB',
406
- r: original[ 0 ],
407
- g: original[ 1 ],
408
- b: original[ 2 ]
409
- };
410
-
411
- },
412
- write: function write( color ) {
413
-
414
- return [ color.r, color.g, color.b ];
415
-
416
- }
417
- },
418
- RGBA_ARRAY: {
419
- read: function read( original ) {
420
-
421
- if ( original.length !== 4 ) return false;
422
- return {
423
- space: 'RGB',
424
- r: original[ 0 ],
425
- g: original[ 1 ],
426
- b: original[ 2 ],
427
- a: original[ 3 ]
428
- };
429
-
430
- },
431
- write: function write( color ) {
432
-
433
- return [ color.r, color.g, color.b, color.a ];
434
-
435
- }
436
- }
437
- }
438
- },
439
- {
440
- litmus: Common.isObject,
441
- conversions: {
442
- RGBA_OBJ: {
443
- read: function read( original ) {
444
-
445
- if ( Common.isNumber( original.r ) && Common.isNumber( original.g ) && Common.isNumber( original.b ) && Common.isNumber( original.a ) ) {
446
-
447
- return {
448
- space: 'RGB',
449
- r: original.r,
450
- g: original.g,
451
- b: original.b,
452
- a: original.a
453
- };
454
-
455
- }
456
- return false;
457
-
458
- },
459
- write: function write( color ) {
460
-
461
- return {
462
- r: color.r,
463
- g: color.g,
464
- b: color.b,
465
- a: color.a
466
- };
467
-
468
- }
469
- },
470
- RGB_OBJ: {
471
- read: function read( original ) {
472
-
473
- if ( Common.isNumber( original.r ) && Common.isNumber( original.g ) && Common.isNumber( original.b ) ) {
474
-
475
- return {
476
- space: 'RGB',
477
- r: original.r,
478
- g: original.g,
479
- b: original.b
480
- };
481
-
482
- }
483
- return false;
484
-
485
- },
486
- write: function write( color ) {
487
-
488
- return {
489
- r: color.r,
490
- g: color.g,
491
- b: color.b
492
- };
493
-
494
- }
495
- },
496
- HSVA_OBJ: {
497
- read: function read( original ) {
498
-
499
- if ( Common.isNumber( original.h ) && Common.isNumber( original.s ) && Common.isNumber( original.v ) && Common.isNumber( original.a ) ) {
500
-
501
- return {
502
- space: 'HSV',
503
- h: original.h,
504
- s: original.s,
505
- v: original.v,
506
- a: original.a
507
- };
508
-
509
- }
510
- return false;
511
-
512
- },
513
- write: function write( color ) {
514
-
515
- return {
516
- h: color.h,
517
- s: color.s,
518
- v: color.v,
519
- a: color.a
520
- };
521
-
522
- }
523
- },
524
- HSV_OBJ: {
525
- read: function read( original ) {
526
-
527
- if ( Common.isNumber( original.h ) && Common.isNumber( original.s ) && Common.isNumber( original.v ) ) {
528
-
529
- return {
530
- space: 'HSV',
531
- h: original.h,
532
- s: original.s,
533
- v: original.v
534
- };
535
-
536
- }
537
- return false;
538
-
539
- },
540
- write: function write( color ) {
541
-
542
- return {
543
- h: color.h,
544
- s: color.s,
545
- v: color.v
546
- };
547
-
548
- }
549
- }
550
- }
551
- } ];
552
- var result = void 0;
553
- var toReturn = void 0;
554
- var interpret = function interpret() {
555
-
556
- toReturn = false;
557
- var original = arguments.length > 1 ? Common.toArray( arguments ) : arguments[ 0 ];
558
- Common.each( INTERPRETATIONS, function ( family ) {
559
-
560
- if ( family.litmus( original ) ) {
561
-
562
- Common.each( family.conversions, function ( conversion, conversionName ) {
563
-
564
- result = conversion.read( original );
565
- if ( toReturn === false && result !== false ) {
566
-
567
- toReturn = result;
568
- result.conversionName = conversionName;
569
- result.conversion = conversion;
570
- return Common.BREAK;
571
-
572
- }
573
-
574
- } );
575
- return Common.BREAK;
576
-
577
- }
578
-
579
- } );
580
- return toReturn;
581
-
582
- };
583
-
584
- var tmpComponent = void 0;
585
- var ColorMath = {
586
- hsv_to_rgb: function hsv_to_rgb( h, s, v ) {
587
-
588
- var hi = Math.floor( h / 60 ) % 6;
589
- var f = h / 60 - Math.floor( h / 60 );
590
- var p = v * ( 1.0 - s );
591
- var q = v * ( 1.0 - f * s );
592
- var t = v * ( 1.0 - ( 1.0 - f ) * s );
593
- var c = [[ v, t, p ], [ q, v, p ], [ p, v, t ], [ p, q, v ], [ t, p, v ], [ v, p, q ]][ hi ];
594
- return {
595
- r: c[ 0 ] * 255,
596
- g: c[ 1 ] * 255,
597
- b: c[ 2 ] * 255
598
- };
599
-
600
- },
601
- rgb_to_hsv: function rgb_to_hsv( r, g, b ) {
602
-
603
- var min = Math.min( r, g, b );
604
- var max = Math.max( r, g, b );
605
- var delta = max - min;
606
- var h = void 0;
607
- var s = void 0;
608
- if ( max !== 0 ) {
609
-
610
- s = delta / max;
611
-
612
- } else {
613
-
614
- return {
615
- h: NaN,
616
- s: 0,
617
- v: 0
618
- };
619
-
620
- }
621
- if ( r === max ) {
622
-
623
- h = ( g - b ) / delta;
624
-
625
- } else if ( g === max ) {
626
-
627
- h = 2 + ( b - r ) / delta;
628
-
629
- } else {
630
-
631
- h = 4 + ( r - g ) / delta;
632
-
633
- }
634
- h /= 6;
635
- if ( h < 0 ) {
636
-
637
- h += 1;
638
-
639
- }
640
- return {
641
- h: h * 360,
642
- s: s,
643
- v: max / 255
644
- };
645
-
646
- },
647
- rgb_to_hex: function rgb_to_hex( r, g, b ) {
648
-
649
- var hex = this.hex_with_component( 0, 2, r );
650
- hex = this.hex_with_component( hex, 1, g );
651
- hex = this.hex_with_component( hex, 0, b );
652
- return hex;
653
-
654
- },
655
- component_from_hex: function component_from_hex( hex, componentIndex ) {
656
-
657
- return hex >> componentIndex * 8 & 0xFF;
658
-
659
- },
660
- hex_with_component: function hex_with_component( hex, componentIndex, value ) {
661
-
662
- return value << ( tmpComponent = componentIndex * 8 ) | hex & ~ ( 0xFF << tmpComponent );
663
-
664
- }
665
- };
666
-
667
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function ( obj ) {
668
-
669
- return typeof obj;
670
-
671
- } : function ( obj ) {
672
-
673
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
674
-
675
- };
676
-
677
-
678
-
679
-
680
-
681
-
682
-
683
-
684
-
685
-
686
-
687
- var classCallCheck = function ( instance, Constructor ) {
688
-
689
- if ( ! ( instance instanceof Constructor ) ) {
690
-
691
- throw new TypeError( "Cannot call a class as a function" );
692
-
693
- }
694
-
695
- };
696
-
697
- var createClass = function () {
698
-
699
- function defineProperties( target, props ) {
700
-
701
- for ( var i = 0; i < props.length; i ++ ) {
702
-
703
- var descriptor = props[ i ];
704
- descriptor.enumerable = descriptor.enumerable || false;
705
- descriptor.configurable = true;
706
- if ( "value" in descriptor ) descriptor.writable = true;
707
- Object.defineProperty( target, descriptor.key, descriptor );
708
-
709
- }
710
-
711
- }
712
-
713
- return function ( Constructor, protoProps, staticProps ) {
714
-
715
- if ( protoProps ) defineProperties( Constructor.prototype, protoProps );
716
- if ( staticProps ) defineProperties( Constructor, staticProps );
717
- return Constructor;
718
-
719
- };
720
-
721
- }();
722
-
723
-
724
-
725
-
726
-
727
-
728
-
729
- var get = function get( object, property, receiver ) {
730
-
731
- if ( object === null ) object = Function.prototype;
732
- var desc = Object.getOwnPropertyDescriptor( object, property );
733
-
734
- if ( desc === undefined ) {
735
-
736
- var parent = Object.getPrototypeOf( object );
737
-
738
- if ( parent === null ) {
739
-
740
- return undefined;
741
-
742
- } else {
743
-
744
- return get( parent, property, receiver );
745
-
746
- }
747
-
748
- } else if ( "value" in desc ) {
749
-
750
- return desc.value;
751
-
752
- } else {
753
-
754
- var getter = desc.get;
755
-
756
- if ( getter === undefined ) {
757
-
758
- return undefined;
759
-
760
- }
761
-
762
- return getter.call( receiver );
763
-
764
- }
765
-
766
- };
767
-
768
- var inherits = function ( subClass, superClass ) {
769
-
770
- if ( typeof superClass !== "function" && superClass !== null ) {
771
-
772
- throw new TypeError( "Super expression must either be null or a function, not " + typeof superClass );
773
-
774
- }
775
-
776
- subClass.prototype = Object.create( superClass && superClass.prototype, {
777
- constructor: {
778
- value: subClass,
779
- enumerable: false,
780
- writable: true,
781
- configurable: true
782
- }
783
- } );
784
- if ( superClass ) Object.setPrototypeOf ? Object.setPrototypeOf( subClass, superClass ) : subClass.__proto__ = superClass;
785
-
786
- };
787
-
788
-
789
-
790
-
791
-
792
-
793
-
794
-
795
-
796
-
797
-
798
- var possibleConstructorReturn = function ( self, call ) {
799
-
800
- if ( ! self ) {
801
-
802
- throw new ReferenceError( "this hasn't been initialised - super() hasn't been called" );
803
-
804
- }
805
-
806
- return call && ( typeof call === "object" || typeof call === "function" ) ? call : self;
807
-
808
- };
809
-
810
- var Color = function () {
811
-
812
- function Color() {
813
-
814
- classCallCheck( this, Color );
815
- this.__state = interpret.apply( this, arguments );
816
- if ( this.__state === false ) {
817
-
818
- throw new Error( 'Failed to interpret color arguments' );
819
-
820
- }
821
- this.__state.a = this.__state.a || 1;
822
-
823
- }
824
- createClass( Color, [ {
825
- key: 'toString',
826
- value: function toString() {
827
-
828
- return colorToString( this );
829
-
830
- }
831
- }, {
832
- key: 'toHexString',
833
- value: function toHexString() {
834
-
835
- return colorToString( this, true );
836
-
837
- }
838
- }, {
839
- key: 'toOriginal',
840
- value: function toOriginal() {
841
-
842
- return this.__state.conversion.write( this );
843
-
844
- }
845
- } ] );
846
- return Color;
847
-
848
- }();
849
- function defineRGBComponent( target, component, componentHexIndex ) {
850
-
851
- Object.defineProperty( target, component, {
852
- get: function get$$1() {
853
-
854
- if ( this.__state.space === 'RGB' ) {
855
-
856
- return this.__state[ component ];
857
-
858
- }
859
- Color.recalculateRGB( this, component, componentHexIndex );
860
- return this.__state[ component ];
861
-
862
- },
863
- set: function set$$1( v ) {
864
-
865
- if ( this.__state.space !== 'RGB' ) {
866
-
867
- Color.recalculateRGB( this, component, componentHexIndex );
868
- this.__state.space = 'RGB';
869
-
870
- }
871
- this.__state[ component ] = v;
872
-
873
- }
874
- } );
875
-
876
- }
877
- function defineHSVComponent( target, component ) {
878
-
879
- Object.defineProperty( target, component, {
880
- get: function get$$1() {
881
-
882
- if ( this.__state.space === 'HSV' ) {
883
-
884
- return this.__state[ component ];
885
-
886
- }
887
- Color.recalculateHSV( this );
888
- return this.__state[ component ];
889
-
890
- },
891
- set: function set$$1( v ) {
892
-
893
- if ( this.__state.space !== 'HSV' ) {
894
-
895
- Color.recalculateHSV( this );
896
- this.__state.space = 'HSV';
897
-
898
- }
899
- this.__state[ component ] = v;
900
-
901
- }
902
- } );
903
-
904
- }
905
- Color.recalculateRGB = function ( color, component, componentHexIndex ) {
906
-
907
- if ( color.__state.space === 'HEX' ) {
908
-
909
- color.__state[ component ] = ColorMath.component_from_hex( color.__state.hex, componentHexIndex );
910
-
911
- } else if ( color.__state.space === 'HSV' ) {
912
-
913
- Common.extend( color.__state, ColorMath.hsv_to_rgb( color.__state.h, color.__state.s, color.__state.v ) );
914
-
915
- } else {
916
-
917
- throw new Error( 'Corrupted color state' );
918
-
919
- }
920
-
921
- };
922
- Color.recalculateHSV = function ( color ) {
923
-
924
- var result = ColorMath.rgb_to_hsv( color.r, color.g, color.b );
925
- Common.extend( color.__state, {
926
- s: result.s,
927
- v: result.v
928
- } );
929
- if ( ! Common.isNaN( result.h ) ) {
930
-
931
- color.__state.h = result.h;
932
-
933
- } else if ( Common.isUndefined( color.__state.h ) ) {
934
-
935
- color.__state.h = 0;
936
-
937
- }
938
-
939
- };
940
- Color.COMPONENTS = [ 'r', 'g', 'b', 'h', 's', 'v', 'hex', 'a' ];
941
- defineRGBComponent( Color.prototype, 'r', 2 );
942
- defineRGBComponent( Color.prototype, 'g', 1 );
943
- defineRGBComponent( Color.prototype, 'b', 0 );
944
- defineHSVComponent( Color.prototype, 'h' );
945
- defineHSVComponent( Color.prototype, 's' );
946
- defineHSVComponent( Color.prototype, 'v' );
947
- Object.defineProperty( Color.prototype, 'a', {
948
- get: function get$$1() {
949
-
950
- return this.__state.a;
951
-
952
- },
953
- set: function set$$1( v ) {
954
-
955
- this.__state.a = v;
956
-
957
- }
958
- } );
959
- Object.defineProperty( Color.prototype, 'hex', {
960
- get: function get$$1() {
961
-
962
- if ( this.__state.space !== 'HEX' ) {
963
-
964
- this.__state.hex = ColorMath.rgb_to_hex( this.r, this.g, this.b );
965
- this.__state.space = 'HEX';
966
-
967
- }
968
- return this.__state.hex;
969
-
970
- },
971
- set: function set$$1( v ) {
972
-
973
- this.__state.space = 'HEX';
974
- this.__state.hex = v;
975
-
976
- }
977
- } );
978
-
979
- var Controller = function () {
980
-
981
- function Controller( object, property ) {
982
-
983
- classCallCheck( this, Controller );
984
- this.initialValue = object[ property ];
985
- this.domElement = document.createElement( 'div' );
986
- this.object = object;
987
- this.property = property;
988
- this.__onChange = undefined;
989
- this.__onFinishChange = undefined;
990
-
991
- }
992
- createClass( Controller, [ {
993
- key: 'onChange',
994
- value: function onChange( fnc ) {
995
-
996
- this.__onChange = fnc;
997
- return this;
998
-
999
- }
1000
- }, {
1001
- key: 'onFinishChange',
1002
- value: function onFinishChange( fnc ) {
1003
-
1004
- this.__onFinishChange = fnc;
1005
- return this;
1006
-
1007
- }
1008
- }, {
1009
- key: 'setValue',
1010
- value: function setValue( newValue ) {
1011
-
1012
- this.object[ this.property ] = newValue;
1013
- if ( this.__onChange ) {
1014
-
1015
- this.__onChange.call( this, newValue );
1016
-
1017
- }
1018
- this.updateDisplay();
1019
- return this;
1020
-
1021
- }
1022
- }, {
1023
- key: 'getValue',
1024
- value: function getValue() {
1025
-
1026
- return this.object[ this.property ];
1027
-
1028
- }
1029
- }, {
1030
- key: 'updateDisplay',
1031
- value: function updateDisplay() {
1032
-
1033
- return this;
1034
-
1035
- }
1036
- }, {
1037
- key: 'isModified',
1038
- value: function isModified() {
1039
-
1040
- return this.initialValue !== this.getValue();
1041
-
1042
- }
1043
- } ] );
1044
- return Controller;
1045
-
1046
- }();
1047
-
1048
- var EVENT_MAP = {
1049
- HTMLEvents: [ 'change' ],
1050
- MouseEvents: [ 'click', 'mousemove', 'mousedown', 'mouseup', 'mouseover' ],
1051
- KeyboardEvents: [ 'keydown' ]
1052
- };
1053
- var EVENT_MAP_INV = {};
1054
- Common.each( EVENT_MAP, function ( v, k ) {
1055
-
1056
- Common.each( v, function ( e ) {
1057
-
1058
- EVENT_MAP_INV[ e ] = k;
1059
-
1060
- } );
1061
-
1062
- } );
1063
- var CSS_VALUE_PIXELS = /(\d+(\.\d+)?)px/;
1064
- function cssValueToPixels( val ) {
1065
-
1066
- if ( val === '0' || Common.isUndefined( val ) ) {
1067
-
1068
- return 0;
1069
-
1070
- }
1071
- var match = val.match( CSS_VALUE_PIXELS );
1072
- if ( ! Common.isNull( match ) ) {
1073
-
1074
- return parseFloat( match[ 1 ] );
1075
-
1076
- }
1077
- return 0;
1078
-
1079
- }
1080
- var dom = {
1081
- makeSelectable: function makeSelectable( elem, selectable ) {
1082
-
1083
- if ( elem === undefined || elem.style === undefined ) return;
1084
- elem.onselectstart = selectable ? function () {
1085
-
1086
- return false;
1087
-
1088
- } : function () {};
1089
- elem.style.MozUserSelect = selectable ? 'auto' : 'none';
1090
- elem.style.KhtmlUserSelect = selectable ? 'auto' : 'none';
1091
- elem.unselectable = selectable ? 'on' : 'off';
1092
-
1093
- },
1094
- makeFullscreen: function makeFullscreen( elem, hor, vert ) {
1095
-
1096
- var vertical = vert;
1097
- var horizontal = hor;
1098
- if ( Common.isUndefined( horizontal ) ) {
1099
-
1100
- horizontal = true;
1101
-
1102
- }
1103
- if ( Common.isUndefined( vertical ) ) {
1104
-
1105
- vertical = true;
1106
-
1107
- }
1108
- elem.style.position = 'absolute';
1109
- if ( horizontal ) {
1110
-
1111
- elem.style.left = 0;
1112
- elem.style.right = 0;
1113
-
1114
- }
1115
- if ( vertical ) {
1116
-
1117
- elem.style.top = 0;
1118
- elem.style.bottom = 0;
1119
-
1120
- }
1121
-
1122
- },
1123
- fakeEvent: function fakeEvent( elem, eventType, pars, aux ) {
1124
-
1125
- var params = pars || {};
1126
- var className = EVENT_MAP_INV[ eventType ];
1127
- if ( ! className ) {
1128
-
1129
- throw new Error( 'Event type ' + eventType + ' not supported.' );
1130
-
1131
- }
1132
- var evt = document.createEvent( className );
1133
- switch ( className ) {
1134
-
1135
- case 'MouseEvents':
1136
- {
1137
-
1138
- var clientX = params.x || params.clientX || 0;
1139
- var clientY = params.y || params.clientY || 0;
1140
- evt.initMouseEvent( eventType, params.bubbles || false, params.cancelable || true, window, params.clickCount || 1, 0,
1141
- 0,
1142
- clientX,
1143
- clientY,
1144
- false, false, false, false, 0, null );
1145
- break;
1146
-
1147
- }
1148
- case 'KeyboardEvents':
1149
- {
1150
-
1151
- var init = evt.initKeyboardEvent || evt.initKeyEvent;
1152
- Common.defaults( params, {
1153
- cancelable: true,
1154
- ctrlKey: false,
1155
- altKey: false,
1156
- shiftKey: false,
1157
- metaKey: false,
1158
- keyCode: undefined,
1159
- charCode: undefined
1160
- } );
1161
- init( eventType, params.bubbles || false, params.cancelable, window, params.ctrlKey, params.altKey, params.shiftKey, params.metaKey, params.keyCode, params.charCode );
1162
- break;
1163
-
1164
- }
1165
- default:
1166
- {
1167
-
1168
- evt.initEvent( eventType, params.bubbles || false, params.cancelable || true );
1169
- break;
1170
-
1171
- }
1172
-
1173
- }
1174
- Common.defaults( evt, aux );
1175
- elem.dispatchEvent( evt );
1176
-
1177
- },
1178
- bind: function bind( elem, event, func, newBool ) {
1179
-
1180
- var bool = newBool || false;
1181
- if ( elem.addEventListener ) {
1182
-
1183
- elem.addEventListener( event, func, bool );
1184
-
1185
- } else if ( elem.attachEvent ) {
1186
-
1187
- elem.attachEvent( 'on' + event, func );
1188
-
1189
- }
1190
- return dom;
1191
-
1192
- },
1193
- unbind: function unbind( elem, event, func, newBool ) {
1194
-
1195
- var bool = newBool || false;
1196
- if ( elem.removeEventListener ) {
1197
-
1198
- elem.removeEventListener( event, func, bool );
1199
-
1200
- } else if ( elem.detachEvent ) {
1201
-
1202
- elem.detachEvent( 'on' + event, func );
1203
-
1204
- }
1205
- return dom;
1206
-
1207
- },
1208
- addClass: function addClass( elem, className ) {
1209
-
1210
- if ( elem.className === undefined ) {
1211
-
1212
- elem.className = className;
1213
-
1214
- } else if ( elem.className !== className ) {
1215
-
1216
- var classes = elem.className.split( / +/ );
1217
- if ( classes.indexOf( className ) === - 1 ) {
1218
-
1219
- classes.push( className );
1220
- elem.className = classes.join( ' ' ).replace( /^\s+/, '' ).replace( /\s+$/, '' );
1221
-
1222
- }
1223
-
1224
- }
1225
- return dom;
1226
-
1227
- },
1228
- removeClass: function removeClass( elem, className ) {
1229
-
1230
- if ( className ) {
1231
-
1232
- if ( elem.className === className ) {
1233
-
1234
- elem.removeAttribute( 'class' );
1235
-
1236
- } else {
1237
-
1238
- var classes = elem.className.split( / +/ );
1239
- var index = classes.indexOf( className );
1240
- if ( index !== - 1 ) {
1241
-
1242
- classes.splice( index, 1 );
1243
- elem.className = classes.join( ' ' );
1244
-
1245
- }
1246
-
1247
- }
1248
-
1249
- } else {
1250
-
1251
- elem.className = undefined;
1252
-
1253
- }
1254
- return dom;
1255
-
1256
- },
1257
- hasClass: function hasClass( elem, className ) {
1258
-
1259
- return new RegExp( '(?:^|\\s+)' + className + '(?:\\s+|$)' ).test( elem.className ) || false;
1260
-
1261
- },
1262
- getWidth: function getWidth( elem ) {
1263
-
1264
- var style = getComputedStyle( elem );
1265
- return cssValueToPixels( style[ 'border-left-width' ] ) + cssValueToPixels( style[ 'border-right-width' ] ) + cssValueToPixels( style[ 'padding-left' ] ) + cssValueToPixels( style[ 'padding-right' ] ) + cssValueToPixels( style.width );
1266
-
1267
- },
1268
- getHeight: function getHeight( elem ) {
1269
-
1270
- var style = getComputedStyle( elem );
1271
- return cssValueToPixels( style[ 'border-top-width' ] ) + cssValueToPixels( style[ 'border-bottom-width' ] ) + cssValueToPixels( style[ 'padding-top' ] ) + cssValueToPixels( style[ 'padding-bottom' ] ) + cssValueToPixels( style.height );
1272
-
1273
- },
1274
- getOffset: function getOffset( el ) {
1275
-
1276
- var elem = el;
1277
- var offset = { left: 0, top: 0 };
1278
- if ( elem.offsetParent ) {
1279
-
1280
- do {
1281
-
1282
- offset.left += elem.offsetLeft;
1283
- offset.top += elem.offsetTop;
1284
- elem = elem.offsetParent;
1285
-
1286
- } while ( elem );
1287
-
1288
- }
1289
- return offset;
1290
-
1291
- },
1292
- isActive: function isActive( elem ) {
1293
-
1294
- return elem === document.activeElement && ( elem.type || elem.href );
1295
-
1296
- }
1297
- };
1298
-
1299
- var BooleanController = function ( _Controller ) {
1300
-
1301
- inherits( BooleanController, _Controller );
1302
- function BooleanController( object, property ) {
1303
-
1304
- classCallCheck( this, BooleanController );
1305
- var _this2 = possibleConstructorReturn( this, ( BooleanController.__proto__ || Object.getPrototypeOf( BooleanController ) ).call( this, object, property ) );
1306
- var _this = _this2;
1307
- _this2.__prev = _this2.getValue();
1308
- _this2.__checkbox = document.createElement( 'input' );
1309
- _this2.__checkbox.setAttribute( 'type', 'checkbox' );
1310
- function onChange() {
1311
-
1312
- _this.setValue( ! _this.__prev );
1313
-
1314
- }
1315
- dom.bind( _this2.__checkbox, 'change', onChange, false );
1316
- _this2.domElement.appendChild( _this2.__checkbox );
1317
- _this2.updateDisplay();
1318
- return _this2;
1319
-
1320
- }
1321
- createClass( BooleanController, [ {
1322
- key: 'setValue',
1323
- value: function setValue( v ) {
1324
-
1325
- var toReturn = get( BooleanController.prototype.__proto__ || Object.getPrototypeOf( BooleanController.prototype ), 'setValue', this ).call( this, v );
1326
- if ( this.__onFinishChange ) {
1327
-
1328
- this.__onFinishChange.call( this, this.getValue() );
1329
-
1330
- }
1331
- this.__prev = this.getValue();
1332
- return toReturn;
1333
-
1334
- }
1335
- }, {
1336
- key: 'updateDisplay',
1337
- value: function updateDisplay() {
1338
-
1339
- if ( this.getValue() === true ) {
1340
-
1341
- this.__checkbox.setAttribute( 'checked', 'checked' );
1342
- this.__checkbox.checked = true;
1343
- this.__prev = true;
1344
-
1345
- } else {
1346
-
1347
- this.__checkbox.checked = false;
1348
- this.__prev = false;
1349
-
1350
- }
1351
- return get( BooleanController.prototype.__proto__ || Object.getPrototypeOf( BooleanController.prototype ), 'updateDisplay', this ).call( this );
1352
-
1353
- }
1354
- } ] );
1355
- return BooleanController;
1356
-
1357
- }( Controller );
1358
-
1359
- var OptionController = function ( _Controller ) {
1360
-
1361
- inherits( OptionController, _Controller );
1362
- function OptionController( object, property, opts ) {
1363
-
1364
- classCallCheck( this, OptionController );
1365
- var _this2 = possibleConstructorReturn( this, ( OptionController.__proto__ || Object.getPrototypeOf( OptionController ) ).call( this, object, property ) );
1366
- var options = opts;
1367
- var _this = _this2;
1368
- _this2.__select = document.createElement( 'select' );
1369
- if ( Common.isArray( options ) ) {
1370
-
1371
- var map = {};
1372
- Common.each( options, function ( element ) {
1373
-
1374
- map[ element ] = element;
1375
-
1376
- } );
1377
- options = map;
1378
-
1379
- }
1380
- Common.each( options, function ( value, key ) {
1381
-
1382
- var opt = document.createElement( 'option' );
1383
- opt.innerHTML = key;
1384
- opt.setAttribute( 'value', value );
1385
- _this.__select.appendChild( opt );
1386
-
1387
- } );
1388
- _this2.updateDisplay();
1389
- dom.bind( _this2.__select, 'change', function () {
1390
-
1391
- var desiredValue = this.options[ this.selectedIndex ].value;
1392
- _this.setValue( desiredValue );
1393
-
1394
- } );
1395
- _this2.domElement.appendChild( _this2.__select );
1396
- return _this2;
1397
-
1398
- }
1399
- createClass( OptionController, [ {
1400
- key: 'setValue',
1401
- value: function setValue( v ) {
1402
-
1403
- var toReturn = get( OptionController.prototype.__proto__ || Object.getPrototypeOf( OptionController.prototype ), 'setValue', this ).call( this, v );
1404
- if ( this.__onFinishChange ) {
1405
-
1406
- this.__onFinishChange.call( this, this.getValue() );
1407
-
1408
- }
1409
- return toReturn;
1410
-
1411
- }
1412
- }, {
1413
- key: 'updateDisplay',
1414
- value: function updateDisplay() {
1415
-
1416
- if ( dom.isActive( this.__select ) ) return this;
1417
- this.__select.value = this.getValue();
1418
- return get( OptionController.prototype.__proto__ || Object.getPrototypeOf( OptionController.prototype ), 'updateDisplay', this ).call( this );
1419
-
1420
- }
1421
- } ] );
1422
- return OptionController;
1423
-
1424
- }( Controller );
1425
-
1426
- var StringController = function ( _Controller ) {
1427
-
1428
- inherits( StringController, _Controller );
1429
- function StringController( object, property ) {
1430
-
1431
- classCallCheck( this, StringController );
1432
- var _this2 = possibleConstructorReturn( this, ( StringController.__proto__ || Object.getPrototypeOf( StringController ) ).call( this, object, property ) );
1433
- var _this = _this2;
1434
- function onChange() {
1435
-
1436
- _this.setValue( _this.__input.value );
1437
-
1438
- }
1439
- function onBlur() {
1440
-
1441
- if ( _this.__onFinishChange ) {
1442
-
1443
- _this.__onFinishChange.call( _this, _this.getValue() );
1444
-
1445
- }
1446
-
1447
- }
1448
- _this2.__input = document.createElement( 'input' );
1449
- _this2.__input.setAttribute( 'type', 'text' );
1450
- dom.bind( _this2.__input, 'keyup', onChange );
1451
- dom.bind( _this2.__input, 'change', onChange );
1452
- dom.bind( _this2.__input, 'blur', onBlur );
1453
- dom.bind( _this2.__input, 'keydown', function ( e ) {
1454
-
1455
- if ( e.keyCode === 13 ) {
1456
-
1457
- this.blur();
1458
-
1459
- }
1460
-
1461
- } );
1462
- _this2.updateDisplay();
1463
- _this2.domElement.appendChild( _this2.__input );
1464
- return _this2;
1465
-
1466
- }
1467
- createClass( StringController, [ {
1468
- key: 'updateDisplay',
1469
- value: function updateDisplay() {
1470
-
1471
- if ( ! dom.isActive( this.__input ) ) {
1472
-
1473
- this.__input.value = this.getValue();
1474
-
1475
- }
1476
- return get( StringController.prototype.__proto__ || Object.getPrototypeOf( StringController.prototype ), 'updateDisplay', this ).call( this );
1477
-
1478
- }
1479
- } ] );
1480
- return StringController;
1481
-
1482
- }( Controller );
1483
-
1484
- function numDecimals( x ) {
1485
-
1486
- var _x = x.toString();
1487
- if ( _x.indexOf( '.' ) > - 1 ) {
1488
-
1489
- return _x.length - _x.indexOf( '.' ) - 1;
1490
-
1491
- }
1492
- return 0;
1493
-
1494
- }
1495
- var NumberController = function ( _Controller ) {
1496
-
1497
- inherits( NumberController, _Controller );
1498
- function NumberController( object, property, params ) {
1499
-
1500
- classCallCheck( this, NumberController );
1501
- var _this = possibleConstructorReturn( this, ( NumberController.__proto__ || Object.getPrototypeOf( NumberController ) ).call( this, object, property ) );
1502
- var _params = params || {};
1503
- _this.__min = _params.min;
1504
- _this.__max = _params.max;
1505
- _this.__step = _params.step;
1506
- if ( Common.isUndefined( _this.__step ) ) {
1507
-
1508
- if ( _this.initialValue === 0 ) {
1509
-
1510
- _this.__impliedStep = 1;
1511
-
1512
- } else {
1513
-
1514
- _this.__impliedStep = Math.pow( 10, Math.floor( Math.log( Math.abs( _this.initialValue ) ) / Math.LN10 ) ) / 10;
1515
-
1516
- }
1517
-
1518
- } else {
1519
-
1520
- _this.__impliedStep = _this.__step;
1521
-
1522
- }
1523
- _this.__precision = numDecimals( _this.__impliedStep );
1524
- return _this;
1525
-
1526
- }
1527
- createClass( NumberController, [ {
1528
- key: 'setValue',
1529
- value: function setValue( v ) {
1530
-
1531
- var _v = v;
1532
- if ( this.__min !== undefined && _v < this.__min ) {
1533
-
1534
- _v = this.__min;
1535
-
1536
- } else if ( this.__max !== undefined && _v > this.__max ) {
1537
-
1538
- _v = this.__max;
1539
-
1540
- }
1541
- if ( this.__step !== undefined && _v % this.__step !== 0 ) {
1542
-
1543
- _v = Math.round( _v / this.__step ) * this.__step;
1544
-
1545
- }
1546
- return get( NumberController.prototype.__proto__ || Object.getPrototypeOf( NumberController.prototype ), 'setValue', this ).call( this, _v );
1547
-
1548
- }
1549
- }, {
1550
- key: 'min',
1551
- value: function min( minValue ) {
1552
-
1553
- this.__min = minValue;
1554
- return this;
1555
-
1556
- }
1557
- }, {
1558
- key: 'max',
1559
- value: function max( maxValue ) {
1560
-
1561
- this.__max = maxValue;
1562
- return this;
1563
-
1564
- }
1565
- }, {
1566
- key: 'step',
1567
- value: function step( stepValue ) {
1568
-
1569
- this.__step = stepValue;
1570
- this.__impliedStep = stepValue;
1571
- this.__precision = numDecimals( stepValue );
1572
- return this;
1573
-
1574
- }
1575
- } ] );
1576
- return NumberController;
1577
-
1578
- }( Controller );
1579
-
1580
- function roundToDecimal( value, decimals ) {
1581
-
1582
- var tenTo = Math.pow( 10, decimals );
1583
- return Math.round( value * tenTo ) / tenTo;
1584
-
1585
- }
1586
- var NumberControllerBox = function ( _NumberController ) {
1587
-
1588
- inherits( NumberControllerBox, _NumberController );
1589
- function NumberControllerBox( object, property, params ) {
1590
-
1591
- classCallCheck( this, NumberControllerBox );
1592
- var _this2 = possibleConstructorReturn( this, ( NumberControllerBox.__proto__ || Object.getPrototypeOf( NumberControllerBox ) ).call( this, object, property, params ) );
1593
- _this2.__truncationSuspended = false;
1594
- var _this = _this2;
1595
- var prevY = void 0;
1596
- function onChange() {
1597
-
1598
- var attempted = parseFloat( _this.__input.value );
1599
- if ( ! Common.isNaN( attempted ) ) {
1600
-
1601
- _this.setValue( attempted );
1602
-
1603
- }
1604
-
1605
- }
1606
- function onFinish() {
1607
-
1608
- if ( _this.__onFinishChange ) {
1609
-
1610
- _this.__onFinishChange.call( _this, _this.getValue() );
1611
-
1612
- }
1613
-
1614
- }
1615
- function onBlur() {
1616
-
1617
- onFinish();
1618
-
1619
- }
1620
- function onMouseDrag( e ) {
1621
-
1622
- var diff = prevY - e.clientY;
1623
- _this.setValue( _this.getValue() + diff * _this.__impliedStep );
1624
- prevY = e.clientY;
1625
-
1626
- }
1627
- function onMouseUp() {
1628
-
1629
- dom.unbind( window, 'mousemove', onMouseDrag );
1630
- dom.unbind( window, 'mouseup', onMouseUp );
1631
- onFinish();
1632
-
1633
- }
1634
- function onMouseDown( e ) {
1635
-
1636
- dom.bind( window, 'mousemove', onMouseDrag );
1637
- dom.bind( window, 'mouseup', onMouseUp );
1638
- prevY = e.clientY;
1639
-
1640
- }
1641
- _this2.__input = document.createElement( 'input' );
1642
- _this2.__input.setAttribute( 'type', 'text' );
1643
- dom.bind( _this2.__input, 'change', onChange );
1644
- dom.bind( _this2.__input, 'blur', onBlur );
1645
- dom.bind( _this2.__input, 'mousedown', onMouseDown );
1646
- dom.bind( _this2.__input, 'keydown', function ( e ) {
1647
-
1648
- if ( e.keyCode === 13 ) {
1649
-
1650
- _this.__truncationSuspended = true;
1651
- this.blur();
1652
- _this.__truncationSuspended = false;
1653
- onFinish();
1654
-
1655
- }
1656
-
1657
- } );
1658
- _this2.updateDisplay();
1659
- _this2.domElement.appendChild( _this2.__input );
1660
- return _this2;
1661
-
1662
- }
1663
- createClass( NumberControllerBox, [ {
1664
- key: 'updateDisplay',
1665
- value: function updateDisplay() {
1666
-
1667
- this.__input.value = this.__truncationSuspended ? this.getValue() : roundToDecimal( this.getValue(), this.__precision );
1668
- return get( NumberControllerBox.prototype.__proto__ || Object.getPrototypeOf( NumberControllerBox.prototype ), 'updateDisplay', this ).call( this );
1669
-
1670
- }
1671
- } ] );
1672
- return NumberControllerBox;
1673
-
1674
- }( NumberController );
1675
-
1676
- function map( v, i1, i2, o1, o2 ) {
1677
-
1678
- return o1 + ( o2 - o1 ) * ( ( v - i1 ) / ( i2 - i1 ) );
1679
-
1680
- }
1681
- var NumberControllerSlider = function ( _NumberController ) {
1682
-
1683
- inherits( NumberControllerSlider, _NumberController );
1684
- function NumberControllerSlider( object, property, min, max, step ) {
1685
-
1686
- classCallCheck( this, NumberControllerSlider );
1687
- var _this2 = possibleConstructorReturn( this, ( NumberControllerSlider.__proto__ || Object.getPrototypeOf( NumberControllerSlider ) ).call( this, object, property, { min: min, max: max, step: step } ) );
1688
- var _this = _this2;
1689
- _this2.__background = document.createElement( 'div' );
1690
- _this2.__foreground = document.createElement( 'div' );
1691
- dom.bind( _this2.__background, 'mousedown', onMouseDown );
1692
- dom.bind( _this2.__background, 'touchstart', onTouchStart );
1693
- dom.addClass( _this2.__background, 'slider' );
1694
- dom.addClass( _this2.__foreground, 'slider-fg' );
1695
- function onMouseDown( e ) {
1696
-
1697
- document.activeElement.blur();
1698
- dom.bind( window, 'mousemove', onMouseDrag );
1699
- dom.bind( window, 'mouseup', onMouseUp );
1700
- onMouseDrag( e );
1701
-
1702
- }
1703
- function onMouseDrag( e ) {
1704
-
1705
- e.preventDefault();
1706
- var bgRect = _this.__background.getBoundingClientRect();
1707
- _this.setValue( map( e.clientX, bgRect.left, bgRect.right, _this.__min, _this.__max ) );
1708
- return false;
1709
-
1710
- }
1711
- function onMouseUp() {
1712
-
1713
- dom.unbind( window, 'mousemove', onMouseDrag );
1714
- dom.unbind( window, 'mouseup', onMouseUp );
1715
- if ( _this.__onFinishChange ) {
1716
-
1717
- _this.__onFinishChange.call( _this, _this.getValue() );
1718
-
1719
- }
1720
-
1721
- }
1722
- function onTouchStart( e ) {
1723
-
1724
- if ( e.touches.length !== 1 ) {
1725
-
1726
- return;
1727
-
1728
- }
1729
- dom.bind( window, 'touchmove', onTouchMove );
1730
- dom.bind( window, 'touchend', onTouchEnd );
1731
- onTouchMove( e );
1732
-
1733
- }
1734
- function onTouchMove( e ) {
1735
-
1736
- var clientX = e.touches[ 0 ].clientX;
1737
- var bgRect = _this.__background.getBoundingClientRect();
1738
- _this.setValue( map( clientX, bgRect.left, bgRect.right, _this.__min, _this.__max ) );
1739
-
1740
- }
1741
- function onTouchEnd() {
1742
-
1743
- dom.unbind( window, 'touchmove', onTouchMove );
1744
- dom.unbind( window, 'touchend', onTouchEnd );
1745
- if ( _this.__onFinishChange ) {
1746
-
1747
- _this.__onFinishChange.call( _this, _this.getValue() );
1748
-
1749
- }
1750
-
1751
- }
1752
- _this2.updateDisplay();
1753
- _this2.__background.appendChild( _this2.__foreground );
1754
- _this2.domElement.appendChild( _this2.__background );
1755
- return _this2;
1756
-
1757
- }
1758
- createClass( NumberControllerSlider, [ {
1759
- key: 'updateDisplay',
1760
- value: function updateDisplay() {
1761
-
1762
- var pct = ( this.getValue() - this.__min ) / ( this.__max - this.__min );
1763
- this.__foreground.style.width = pct * 100 + '%';
1764
- return get( NumberControllerSlider.prototype.__proto__ || Object.getPrototypeOf( NumberControllerSlider.prototype ), 'updateDisplay', this ).call( this );
1765
-
1766
- }
1767
- } ] );
1768
- return NumberControllerSlider;
1769
-
1770
- }( NumberController );
1771
-
1772
- var FunctionController = function ( _Controller ) {
1773
-
1774
- inherits( FunctionController, _Controller );
1775
- function FunctionController( object, property, text ) {
1776
-
1777
- classCallCheck( this, FunctionController );
1778
- var _this2 = possibleConstructorReturn( this, ( FunctionController.__proto__ || Object.getPrototypeOf( FunctionController ) ).call( this, object, property ) );
1779
- var _this = _this2;
1780
- _this2.__button = document.createElement( 'div' );
1781
- _this2.__button.innerHTML = text === undefined ? 'Fire' : text;
1782
- dom.bind( _this2.__button, 'click', function ( e ) {
1783
-
1784
- e.preventDefault();
1785
- _this.fire();
1786
- return false;
1787
-
1788
- } );
1789
- dom.addClass( _this2.__button, 'button' );
1790
- _this2.domElement.appendChild( _this2.__button );
1791
- return _this2;
1792
-
1793
- }
1794
- createClass( FunctionController, [ {
1795
- key: 'fire',
1796
- value: function fire() {
1797
-
1798
- if ( this.__onChange ) {
1799
-
1800
- this.__onChange.call( this );
1801
-
1802
- }
1803
- this.getValue().call( this.object );
1804
- if ( this.__onFinishChange ) {
1805
-
1806
- this.__onFinishChange.call( this, this.getValue() );
1807
-
1808
- }
1809
-
1810
- }
1811
- } ] );
1812
- return FunctionController;
1813
-
1814
- }( Controller );
1815
-
1816
- var ColorController = function ( _Controller ) {
1817
-
1818
- inherits( ColorController, _Controller );
1819
- function ColorController( object, property ) {
1820
-
1821
- classCallCheck( this, ColorController );
1822
- var _this2 = possibleConstructorReturn( this, ( ColorController.__proto__ || Object.getPrototypeOf( ColorController ) ).call( this, object, property ) );
1823
- _this2.__color = new Color( _this2.getValue() );
1824
- _this2.__temp = new Color( 0 );
1825
- var _this = _this2;
1826
- _this2.domElement = document.createElement( 'div' );
1827
- dom.makeSelectable( _this2.domElement, false );
1828
- _this2.__selector = document.createElement( 'div' );
1829
- _this2.__selector.className = 'selector';
1830
- _this2.__saturation_field = document.createElement( 'div' );
1831
- _this2.__saturation_field.className = 'saturation-field';
1832
- _this2.__field_knob = document.createElement( 'div' );
1833
- _this2.__field_knob.className = 'field-knob';
1834
- _this2.__field_knob_border = '2px solid ';
1835
- _this2.__hue_knob = document.createElement( 'div' );
1836
- _this2.__hue_knob.className = 'hue-knob';
1837
- _this2.__hue_field = document.createElement( 'div' );
1838
- _this2.__hue_field.className = 'hue-field';
1839
- _this2.__input = document.createElement( 'input' );
1840
- _this2.__input.type = 'text';
1841
- _this2.__input_textShadow = '0 1px 1px ';
1842
- dom.bind( _this2.__input, 'keydown', function ( e ) {
1843
-
1844
- if ( e.keyCode === 13 ) {
1845
-
1846
- onBlur.call( this );
1847
-
1848
- }
1849
-
1850
- } );
1851
- dom.bind( _this2.__input, 'blur', onBlur );
1852
- dom.bind( _this2.__selector, 'mousedown', function () {
1853
-
1854
- dom.addClass( this, 'drag' ).bind( window, 'mouseup', function () {
1855
-
1856
- dom.removeClass( _this.__selector, 'drag' );
1857
-
1858
- } );
1859
-
1860
- } );
1861
- dom.bind( _this2.__selector, 'touchstart', function () {
1862
-
1863
- dom.addClass( this, 'drag' ).bind( window, 'touchend', function () {
1864
-
1865
- dom.removeClass( _this.__selector, 'drag' );
1866
-
1867
- } );
1868
-
1869
- } );
1870
- var valueField = document.createElement( 'div' );
1871
- Common.extend( _this2.__selector.style, {
1872
- width: '122px',
1873
- height: '102px',
1874
- padding: '3px',
1875
- backgroundColor: '#222',
1876
- boxShadow: '0px 1px 3px rgba(0,0,0,0.3)'
1877
- } );
1878
- Common.extend( _this2.__field_knob.style, {
1879
- position: 'absolute',
1880
- width: '12px',
1881
- height: '12px',
1882
- border: _this2.__field_knob_border + ( _this2.__color.v < 0.5 ? '#fff' : '#000' ),
1883
- boxShadow: '0px 1px 3px rgba(0,0,0,0.5)',
1884
- borderRadius: '12px',
1885
- zIndex: 1
1886
- } );
1887
- Common.extend( _this2.__hue_knob.style, {
1888
- position: 'absolute',
1889
- width: '15px',
1890
- height: '2px',
1891
- borderRight: '4px solid #fff',
1892
- zIndex: 1
1893
- } );
1894
- Common.extend( _this2.__saturation_field.style, {
1895
- width: '100px',
1896
- height: '100px',
1897
- border: '1px solid #555',
1898
- marginRight: '3px',
1899
- display: 'inline-block',
1900
- cursor: 'pointer'
1901
- } );
1902
- Common.extend( valueField.style, {
1903
- width: '100%',
1904
- height: '100%',
1905
- background: 'none'
1906
- } );
1907
- linearGradient( valueField, 'top', 'rgba(0,0,0,0)', '#000' );
1908
- Common.extend( _this2.__hue_field.style, {
1909
- width: '15px',
1910
- height: '100px',
1911
- border: '1px solid #555',
1912
- cursor: 'ns-resize',
1913
- position: 'absolute',
1914
- top: '3px',
1915
- right: '3px'
1916
- } );
1917
- hueGradient( _this2.__hue_field );
1918
- Common.extend( _this2.__input.style, {
1919
- outline: 'none',
1920
- textAlign: 'center',
1921
- color: '#fff',
1922
- border: 0,
1923
- fontWeight: 'bold',
1924
- textShadow: _this2.__input_textShadow + 'rgba(0,0,0,0.7)'
1925
- } );
1926
- dom.bind( _this2.__saturation_field, 'mousedown', fieldDown );
1927
- dom.bind( _this2.__saturation_field, 'touchstart', fieldDown );
1928
- dom.bind( _this2.__field_knob, 'mousedown', fieldDown );
1929
- dom.bind( _this2.__field_knob, 'touchstart', fieldDown );
1930
- dom.bind( _this2.__hue_field, 'mousedown', fieldDownH );
1931
- dom.bind( _this2.__hue_field, 'touchstart', fieldDownH );
1932
- function fieldDown( e ) {
1933
-
1934
- setSV( e );
1935
- dom.bind( window, 'mousemove', setSV );
1936
- dom.bind( window, 'touchmove', setSV );
1937
- dom.bind( window, 'mouseup', fieldUpSV );
1938
- dom.bind( window, 'touchend', fieldUpSV );
1939
-
1940
- }
1941
- function fieldDownH( e ) {
1942
-
1943
- setH( e );
1944
- dom.bind( window, 'mousemove', setH );
1945
- dom.bind( window, 'touchmove', setH );
1946
- dom.bind( window, 'mouseup', fieldUpH );
1947
- dom.bind( window, 'touchend', fieldUpH );
1948
-
1949
- }
1950
- function fieldUpSV() {
1951
-
1952
- dom.unbind( window, 'mousemove', setSV );
1953
- dom.unbind( window, 'touchmove', setSV );
1954
- dom.unbind( window, 'mouseup', fieldUpSV );
1955
- dom.unbind( window, 'touchend', fieldUpSV );
1956
- onFinish();
1957
-
1958
- }
1959
- function fieldUpH() {
1960
-
1961
- dom.unbind( window, 'mousemove', setH );
1962
- dom.unbind( window, 'touchmove', setH );
1963
- dom.unbind( window, 'mouseup', fieldUpH );
1964
- dom.unbind( window, 'touchend', fieldUpH );
1965
- onFinish();
1966
-
1967
- }
1968
- function onBlur() {
1969
-
1970
- var i = interpret( this.value );
1971
- if ( i !== false ) {
1972
-
1973
- _this.__color.__state = i;
1974
- _this.setValue( _this.__color.toOriginal() );
1975
-
1976
- } else {
1977
-
1978
- this.value = _this.__color.toString();
1979
-
1980
- }
1981
-
1982
- }
1983
- function onFinish() {
1984
-
1985
- if ( _this.__onFinishChange ) {
1986
-
1987
- _this.__onFinishChange.call( _this, _this.__color.toOriginal() );
1988
-
1989
- }
1990
-
1991
- }
1992
- _this2.__saturation_field.appendChild( valueField );
1993
- _this2.__selector.appendChild( _this2.__field_knob );
1994
- _this2.__selector.appendChild( _this2.__saturation_field );
1995
- _this2.__selector.appendChild( _this2.__hue_field );
1996
- _this2.__hue_field.appendChild( _this2.__hue_knob );
1997
- _this2.domElement.appendChild( _this2.__input );
1998
- _this2.domElement.appendChild( _this2.__selector );
1999
- _this2.updateDisplay();
2000
- function setSV( e ) {
2001
-
2002
- if ( e.type.indexOf( 'touch' ) === - 1 ) {
2003
-
2004
- e.preventDefault();
2005
-
2006
- }
2007
- var fieldRect = _this.__saturation_field.getBoundingClientRect();
2008
- var _ref = e.touches && e.touches[ 0 ] || e,
2009
- clientX = _ref.clientX,
2010
- clientY = _ref.clientY;
2011
- var s = ( clientX - fieldRect.left ) / ( fieldRect.right - fieldRect.left );
2012
- var v = 1 - ( clientY - fieldRect.top ) / ( fieldRect.bottom - fieldRect.top );
2013
- if ( v > 1 ) {
2014
-
2015
- v = 1;
2016
-
2017
- } else if ( v < 0 ) {
2018
-
2019
- v = 0;
2020
-
2021
- }
2022
- if ( s > 1 ) {
2023
-
2024
- s = 1;
2025
-
2026
- } else if ( s < 0 ) {
2027
-
2028
- s = 0;
2029
-
2030
- }
2031
- _this.__color.v = v;
2032
- _this.__color.s = s;
2033
- _this.setValue( _this.__color.toOriginal() );
2034
- return false;
2035
-
2036
- }
2037
- function setH( e ) {
2038
-
2039
- if ( e.type.indexOf( 'touch' ) === - 1 ) {
2040
-
2041
- e.preventDefault();
2042
-
2043
- }
2044
- var fieldRect = _this.__hue_field.getBoundingClientRect();
2045
- var _ref2 = e.touches && e.touches[ 0 ] || e,
2046
- clientY = _ref2.clientY;
2047
- var h = 1 - ( clientY - fieldRect.top ) / ( fieldRect.bottom - fieldRect.top );
2048
- if ( h > 1 ) {
2049
-
2050
- h = 1;
2051
-
2052
- } else if ( h < 0 ) {
2053
-
2054
- h = 0;
2055
-
2056
- }
2057
- _this.__color.h = h * 360;
2058
- _this.setValue( _this.__color.toOriginal() );
2059
- return false;
2060
-
2061
- }
2062
- return _this2;
2063
-
2064
- }
2065
- createClass( ColorController, [ {
2066
- key: 'updateDisplay',
2067
- value: function updateDisplay() {
2068
-
2069
- var i = interpret( this.getValue() );
2070
- if ( i !== false ) {
2071
-
2072
- var mismatch = false;
2073
- Common.each( Color.COMPONENTS, function ( component ) {
2074
-
2075
- if ( ! Common.isUndefined( i[ component ] ) && ! Common.isUndefined( this.__color.__state[ component ] ) && i[ component ] !== this.__color.__state[ component ] ) {
2076
-
2077
- mismatch = true;
2078
- return {};
2079
-
2080
- }
2081
-
2082
- }, this );
2083
- if ( mismatch ) {
2084
-
2085
- Common.extend( this.__color.__state, i );
2086
-
2087
- }
2088
-
2089
- }
2090
- Common.extend( this.__temp.__state, this.__color.__state );
2091
- this.__temp.a = 1;
2092
- var flip = this.__color.v < 0.5 || this.__color.s > 0.5 ? 255 : 0;
2093
- var _flip = 255 - flip;
2094
- Common.extend( this.__field_knob.style, {
2095
- marginLeft: 100 * this.__color.s - 7 + 'px',
2096
- marginTop: 100 * ( 1 - this.__color.v ) - 7 + 'px',
2097
- backgroundColor: this.__temp.toHexString(),
2098
- border: this.__field_knob_border + 'rgb(' + flip + ',' + flip + ',' + flip + ')'
2099
- } );
2100
- this.__hue_knob.style.marginTop = ( 1 - this.__color.h / 360 ) * 100 + 'px';
2101
- this.__temp.s = 1;
2102
- this.__temp.v = 1;
2103
- linearGradient( this.__saturation_field, 'left', '#fff', this.__temp.toHexString() );
2104
- this.__input.value = this.__color.toString();
2105
- Common.extend( this.__input.style, {
2106
- backgroundColor: this.__color.toHexString(),
2107
- color: 'rgb(' + flip + ',' + flip + ',' + flip + ')',
2108
- textShadow: this.__input_textShadow + 'rgba(' + _flip + ',' + _flip + ',' + _flip + ',.7)'
2109
- } );
2110
-
2111
- }
2112
- } ] );
2113
- return ColorController;
2114
-
2115
- }( Controller );
2116
- var vendors = [ '-moz-', '-o-', '-webkit-', '-ms-', '' ];
2117
- function linearGradient( elem, x, a, b ) {
2118
-
2119
- elem.style.background = '';
2120
- Common.each( vendors, function ( vendor ) {
2121
-
2122
- elem.style.cssText += 'background: ' + vendor + 'linear-gradient(' + x + ', ' + a + ' 0%, ' + b + ' 100%); ';
2123
-
2124
- } );
2125
-
2126
- }
2127
- function hueGradient( elem ) {
2128
-
2129
- elem.style.background = '';
2130
- elem.style.cssText += 'background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);';
2131
- elem.style.cssText += 'background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);';
2132
- elem.style.cssText += 'background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);';
2133
- elem.style.cssText += 'background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);';
2134
- elem.style.cssText += 'background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);';
2135
-
2136
- }
2137
-
2138
- var css = {
2139
- load: function load( url, indoc ) {
2140
-
2141
- var doc = indoc || document;
2142
- var link = doc.createElement( 'link' );
2143
- link.type = 'text/css';
2144
- link.rel = 'stylesheet';
2145
- link.href = url;
2146
- doc.getElementsByTagName( 'head' )[ 0 ].appendChild( link );
2147
-
2148
- },
2149
- inject: function inject( cssContent, indoc ) {
2150
-
2151
- var doc = indoc || document;
2152
- var injected = document.createElement( 'style' );
2153
- injected.type = 'text/css';
2154
- injected.innerHTML = cssContent;
2155
- var head = doc.getElementsByTagName( 'head' )[ 0 ];
2156
- try {
2157
-
2158
- head.appendChild( injected );
2159
-
2160
- } catch ( e ) {
2161
- }
2162
-
2163
- }
2164
- };
2165
-
2166
- var saveDialogContents = "<div id=\"dg-save\" class=\"dg dialogue\">\n\n Here's the new load parameter for your <code>GUI</code>'s constructor:\n\n <textarea id=\"dg-new-constructor\"></textarea>\n\n <div id=\"dg-save-locally\">\n\n <input id=\"dg-local-storage\" type=\"checkbox\"/> Automatically save\n values to <code>localStorage</code> on exit.\n\n <div id=\"dg-local-explain\">The values saved to <code>localStorage</code> will\n override those passed to <code>dat.GUI</code>'s constructor. This makes it\n easier to work incrementally, but <code>localStorage</code> is fragile,\n and your friends may not see the same values you do.\n\n </div>\n\n </div>\n\n</div>";
2167
-
2168
- var ControllerFactory = function ControllerFactory( object, property ) {
2169
-
2170
- var initialValue = object[ property ];
2171
- if ( Common.isArray( arguments[ 2 ] ) || Common.isObject( arguments[ 2 ] ) ) {
2172
-
2173
- return new OptionController( object, property, arguments[ 2 ] );
2174
-
2175
- }
2176
- if ( Common.isNumber( initialValue ) ) {
2177
-
2178
- if ( Common.isNumber( arguments[ 2 ] ) && Common.isNumber( arguments[ 3 ] ) ) {
2179
-
2180
- if ( Common.isNumber( arguments[ 4 ] ) ) {
2181
-
2182
- return new NumberControllerSlider( object, property, arguments[ 2 ], arguments[ 3 ], arguments[ 4 ] );
2183
-
2184
- }
2185
- return new NumberControllerSlider( object, property, arguments[ 2 ], arguments[ 3 ] );
2186
-
2187
- }
2188
- if ( Common.isNumber( arguments[ 4 ] ) ) {
2189
-
2190
- return new NumberControllerBox( object, property, { min: arguments[ 2 ], max: arguments[ 3 ], step: arguments[ 4 ] } );
2191
-
2192
- }
2193
- return new NumberControllerBox( object, property, { min: arguments[ 2 ], max: arguments[ 3 ] } );
2194
-
2195
- }
2196
- if ( Common.isString( initialValue ) ) {
2197
-
2198
- return new StringController( object, property );
2199
-
2200
- }
2201
- if ( Common.isFunction( initialValue ) ) {
2202
-
2203
- return new FunctionController( object, property, '' );
2204
-
2205
- }
2206
- if ( Common.isBoolean( initialValue ) ) {
2207
-
2208
- return new BooleanController( object, property );
2209
-
2210
- }
2211
- return null;
2212
-
2213
- };
2214
-
2215
- function requestAnimationFrame( callback ) {
2216
-
2217
- setTimeout( callback, 1000 / 60 );
2218
-
2219
- }
2220
- var requestAnimationFrame$1 = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || requestAnimationFrame;
2221
-
2222
- var CenteredDiv = function () {
2223
-
2224
- function CenteredDiv() {
2225
-
2226
- classCallCheck( this, CenteredDiv );
2227
- this.backgroundElement = document.createElement( 'div' );
2228
- Common.extend( this.backgroundElement.style, {
2229
- backgroundColor: 'rgba(0,0,0,0.8)',
2230
- top: 0,
2231
- left: 0,
2232
- display: 'none',
2233
- zIndex: '1000',
2234
- opacity: 0,
2235
- WebkitTransition: 'opacity 0.2s linear',
2236
- transition: 'opacity 0.2s linear'
2237
- } );
2238
- dom.makeFullscreen( this.backgroundElement );
2239
- this.backgroundElement.style.position = 'fixed';
2240
- this.domElement = document.createElement( 'div' );
2241
- Common.extend( this.domElement.style, {
2242
- position: 'fixed',
2243
- display: 'none',
2244
- zIndex: '1001',
2245
- opacity: 0,
2246
- WebkitTransition: '-webkit-transform 0.2s ease-out, opacity 0.2s linear',
2247
- transition: 'transform 0.2s ease-out, opacity 0.2s linear'
2248
- } );
2249
- document.body.appendChild( this.backgroundElement );
2250
- document.body.appendChild( this.domElement );
2251
- var _this = this;
2252
- dom.bind( this.backgroundElement, 'click', function () {
2253
-
2254
- _this.hide();
2255
-
2256
- } );
2257
-
2258
- }
2259
- createClass( CenteredDiv, [ {
2260
- key: 'show',
2261
- value: function show() {
2262
-
2263
- var _this = this;
2264
- this.backgroundElement.style.display = 'block';
2265
- this.domElement.style.display = 'block';
2266
- this.domElement.style.opacity = 0;
2267
- this.domElement.style.webkitTransform = 'scale(1.1)';
2268
- this.layout();
2269
- Common.defer( function () {
2270
-
2271
- _this.backgroundElement.style.opacity = 1;
2272
- _this.domElement.style.opacity = 1;
2273
- _this.domElement.style.webkitTransform = 'scale(1)';
2274
-
2275
- } );
2276
-
2277
- }
2278
- }, {
2279
- key: 'hide',
2280
- value: function hide() {
2281
-
2282
- var _this = this;
2283
- var hide = function hide() {
2284
-
2285
- _this.domElement.style.display = 'none';
2286
- _this.backgroundElement.style.display = 'none';
2287
- dom.unbind( _this.domElement, 'webkitTransitionEnd', hide );
2288
- dom.unbind( _this.domElement, 'transitionend', hide );
2289
- dom.unbind( _this.domElement, 'oTransitionEnd', hide );
2290
-
2291
- };
2292
- dom.bind( this.domElement, 'webkitTransitionEnd', hide );
2293
- dom.bind( this.domElement, 'transitionend', hide );
2294
- dom.bind( this.domElement, 'oTransitionEnd', hide );
2295
- this.backgroundElement.style.opacity = 0;
2296
- this.domElement.style.opacity = 0;
2297
- this.domElement.style.webkitTransform = 'scale(1.1)';
2298
-
2299
- }
2300
- }, {
2301
- key: 'layout',
2302
- value: function layout() {
2303
-
2304
- this.domElement.style.left = window.innerWidth / 2 - dom.getWidth( this.domElement ) / 2 + 'px';
2305
- this.domElement.style.top = window.innerHeight / 2 - dom.getHeight( this.domElement ) / 2 + 'px';
2306
-
2307
- }
2308
- } ] );
2309
- return CenteredDiv;
2310
-
2311
- }();
2312
-
2313
- var styleSheet = ___$insertStyle( ".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n" );
2314
-
2315
- css.inject( styleSheet );
2316
- var CSS_NAMESPACE = 'dg';
2317
- var HIDE_KEY_CODE = 72;
2318
- var CLOSE_BUTTON_HEIGHT = 20;
2319
- var DEFAULT_DEFAULT_PRESET_NAME = 'Default';
2320
- var SUPPORTS_LOCAL_STORAGE = function () {
2321
-
2322
- try {
2323
-
2324
- return !! window.localStorage;
2325
-
2326
- } catch ( e ) {
2327
-
2328
- return false;
2329
-
2330
- }
2331
-
2332
- }();
2333
- var SAVE_DIALOGUE = void 0;
2334
- var autoPlaceVirgin = true;
2335
- var autoPlaceContainer = void 0;
2336
- var hide = false;
2337
- var hideableGuis = [];
2338
- var GUI = function GUI( pars ) {
2339
-
2340
- var _this = this;
2341
- var params = pars || {};
2342
- this.domElement = document.createElement( 'div' );
2343
- this.__ul = document.createElement( 'ul' );
2344
- this.domElement.appendChild( this.__ul );
2345
- dom.addClass( this.domElement, CSS_NAMESPACE );
2346
- this.__folders = {};
2347
- this.__controllers = [];
2348
- this.__rememberedObjects = [];
2349
- this.__rememberedObjectIndecesToControllers = [];
2350
- this.__listening = [];
2351
- params = Common.defaults( params, {
2352
- closeOnTop: false,
2353
- autoPlace: true,
2354
- width: GUI.DEFAULT_WIDTH
2355
- } );
2356
- params = Common.defaults( params, {
2357
- resizable: params.autoPlace,
2358
- hideable: params.autoPlace
2359
- } );
2360
- if ( ! Common.isUndefined( params.load ) ) {
2361
-
2362
- if ( params.preset ) {
2363
-
2364
- params.load.preset = params.preset;
2365
-
2366
- }
2367
-
2368
- } else {
2369
-
2370
- params.load = { preset: DEFAULT_DEFAULT_PRESET_NAME };
2371
-
2372
- }
2373
- if ( Common.isUndefined( params.parent ) && params.hideable ) {
2374
-
2375
- hideableGuis.push( this );
2376
-
2377
- }
2378
- params.resizable = Common.isUndefined( params.parent ) && params.resizable;
2379
- if ( params.autoPlace && Common.isUndefined( params.scrollable ) ) {
2380
-
2381
- params.scrollable = true;
2382
-
2383
- }
2384
- var useLocalStorage = SUPPORTS_LOCAL_STORAGE && localStorage.getItem( getLocalStorageHash( this, 'isLocal' ) ) === 'true';
2385
- var saveToLocalStorage = void 0;
2386
- var titleRow = void 0;
2387
- Object.defineProperties( this,
2388
- {
2389
- parent: {
2390
- get: function get$$1() {
2391
-
2392
- return params.parent;
2393
-
2394
- }
2395
- },
2396
- scrollable: {
2397
- get: function get$$1() {
2398
-
2399
- return params.scrollable;
2400
-
2401
- }
2402
- },
2403
- autoPlace: {
2404
- get: function get$$1() {
2405
-
2406
- return params.autoPlace;
2407
-
2408
- }
2409
- },
2410
- closeOnTop: {
2411
- get: function get$$1() {
2412
-
2413
- return params.closeOnTop;
2414
-
2415
- }
2416
- },
2417
- preset: {
2418
- get: function get$$1() {
2419
-
2420
- if ( _this.parent ) {
2421
-
2422
- return _this.getRoot().preset;
2423
-
2424
- }
2425
- return params.load.preset;
2426
-
2427
- },
2428
- set: function set$$1( v ) {
2429
-
2430
- if ( _this.parent ) {
2431
-
2432
- _this.getRoot().preset = v;
2433
-
2434
- } else {
2435
-
2436
- params.load.preset = v;
2437
-
2438
- }
2439
- setPresetSelectIndex( this );
2440
- _this.revert();
2441
-
2442
- }
2443
- },
2444
- width: {
2445
- get: function get$$1() {
2446
-
2447
- return params.width;
2448
-
2449
- },
2450
- set: function set$$1( v ) {
2451
-
2452
- params.width = v;
2453
- setWidth( _this, v );
2454
-
2455
- }
2456
- },
2457
- name: {
2458
- get: function get$$1() {
2459
-
2460
- return params.name;
2461
-
2462
- },
2463
- set: function set$$1( v ) {
2464
-
2465
- params.name = v;
2466
- if ( titleRow ) {
2467
-
2468
- titleRow.innerHTML = params.name;
2469
-
2470
- }
2471
-
2472
- }
2473
- },
2474
- closed: {
2475
- get: function get$$1() {
2476
-
2477
- return params.closed;
2478
-
2479
- },
2480
- set: function set$$1( v ) {
2481
-
2482
- params.closed = v;
2483
- if ( params.closed ) {
2484
-
2485
- dom.addClass( _this.__ul, GUI.CLASS_CLOSED );
2486
-
2487
- } else {
2488
-
2489
- dom.removeClass( _this.__ul, GUI.CLASS_CLOSED );
2490
-
2491
- }
2492
- this.onResize();
2493
- if ( _this.__closeButton ) {
2494
-
2495
- _this.__closeButton.innerHTML = v ? GUI.TEXT_OPEN : GUI.TEXT_CLOSED;
2496
-
2497
- }
2498
-
2499
- }
2500
- },
2501
- load: {
2502
- get: function get$$1() {
2503
-
2504
- return params.load;
2505
-
2506
- }
2507
- },
2508
- useLocalStorage: {
2509
- get: function get$$1() {
2510
-
2511
- return useLocalStorage;
2512
-
2513
- },
2514
- set: function set$$1( bool ) {
2515
-
2516
- if ( SUPPORTS_LOCAL_STORAGE ) {
2517
-
2518
- useLocalStorage = bool;
2519
- if ( bool ) {
2520
-
2521
- dom.bind( window, 'unload', saveToLocalStorage );
2522
-
2523
- } else {
2524
-
2525
- dom.unbind( window, 'unload', saveToLocalStorage );
2526
-
2527
- }
2528
- localStorage.setItem( getLocalStorageHash( _this, 'isLocal' ), bool );
2529
-
2530
- }
2531
-
2532
- }
2533
- }
2534
- } );
2535
- if ( Common.isUndefined( params.parent ) ) {
2536
-
2537
- this.closed = params.closed || false;
2538
- dom.addClass( this.domElement, GUI.CLASS_MAIN );
2539
- dom.makeSelectable( this.domElement, false );
2540
- if ( SUPPORTS_LOCAL_STORAGE ) {
2541
-
2542
- if ( useLocalStorage ) {
2543
-
2544
- _this.useLocalStorage = true;
2545
- var savedGui = localStorage.getItem( getLocalStorageHash( this, 'gui' ) );
2546
- if ( savedGui ) {
2547
-
2548
- params.load = JSON.parse( savedGui );
2549
-
2550
- }
2551
-
2552
- }
2553
-
2554
- }
2555
- this.__closeButton = document.createElement( 'div' );
2556
- this.__closeButton.innerHTML = GUI.TEXT_CLOSED;
2557
- dom.addClass( this.__closeButton, GUI.CLASS_CLOSE_BUTTON );
2558
- if ( params.closeOnTop ) {
2559
-
2560
- dom.addClass( this.__closeButton, GUI.CLASS_CLOSE_TOP );
2561
- this.domElement.insertBefore( this.__closeButton, this.domElement.childNodes[ 0 ] );
2562
-
2563
- } else {
2564
-
2565
- dom.addClass( this.__closeButton, GUI.CLASS_CLOSE_BOTTOM );
2566
- this.domElement.appendChild( this.__closeButton );
2567
-
2568
- }
2569
- dom.bind( this.__closeButton, 'click', function () {
2570
-
2571
- _this.closed = ! _this.closed;
2572
-
2573
- } );
2574
-
2575
- } else {
2576
-
2577
- if ( params.closed === undefined ) {
2578
-
2579
- params.closed = true;
2580
-
2581
- }
2582
- var titleRowName = document.createTextNode( params.name );
2583
- dom.addClass( titleRowName, 'controller-name' );
2584
- titleRow = addRow( _this, titleRowName );
2585
- var onClickTitle = function onClickTitle( e ) {
2586
-
2587
- e.preventDefault();
2588
- _this.closed = ! _this.closed;
2589
- return false;
2590
-
2591
- };
2592
- dom.addClass( this.__ul, GUI.CLASS_CLOSED );
2593
- dom.addClass( titleRow, 'title' );
2594
- dom.bind( titleRow, 'click', onClickTitle );
2595
- if ( ! params.closed ) {
2596
-
2597
- this.closed = false;
2598
-
2599
- }
2600
-
2601
- }
2602
- if ( params.autoPlace ) {
2603
-
2604
- if ( Common.isUndefined( params.parent ) ) {
2605
-
2606
- if ( autoPlaceVirgin ) {
2607
-
2608
- autoPlaceContainer = document.createElement( 'div' );
2609
- dom.addClass( autoPlaceContainer, CSS_NAMESPACE );
2610
- dom.addClass( autoPlaceContainer, GUI.CLASS_AUTO_PLACE_CONTAINER );
2611
- document.body.appendChild( autoPlaceContainer );
2612
- autoPlaceVirgin = false;
2613
-
2614
- }
2615
- autoPlaceContainer.appendChild( this.domElement );
2616
- dom.addClass( this.domElement, GUI.CLASS_AUTO_PLACE );
2617
-
2618
- }
2619
- if ( ! this.parent ) {
2620
-
2621
- setWidth( _this, params.width );
2622
-
2623
- }
2624
-
2625
- }
2626
- this.__resizeHandler = function () {
2627
-
2628
- _this.onResizeDebounced();
2629
-
2630
- };
2631
- dom.bind( window, 'resize', this.__resizeHandler );
2632
- dom.bind( this.__ul, 'webkitTransitionEnd', this.__resizeHandler );
2633
- dom.bind( this.__ul, 'transitionend', this.__resizeHandler );
2634
- dom.bind( this.__ul, 'oTransitionEnd', this.__resizeHandler );
2635
- this.onResize();
2636
- if ( params.resizable ) {
2637
-
2638
- addResizeHandle( this );
2639
-
2640
- }
2641
- saveToLocalStorage = function saveToLocalStorage() {
2642
-
2643
- if ( SUPPORTS_LOCAL_STORAGE && localStorage.getItem( getLocalStorageHash( _this, 'isLocal' ) ) === 'true' ) {
2644
-
2645
- localStorage.setItem( getLocalStorageHash( _this, 'gui' ), JSON.stringify( _this.getSaveObject() ) );
2646
-
2647
- }
2648
-
2649
- };
2650
- this.saveToLocalStorageIfPossible = saveToLocalStorage;
2651
- function resetWidth() {
2652
-
2653
- var root = _this.getRoot();
2654
- root.width += 1;
2655
- Common.defer( function () {
2656
-
2657
- root.width -= 1;
2658
-
2659
- } );
2660
-
2661
- }
2662
- if ( ! params.parent ) {
2663
-
2664
- resetWidth();
2665
-
2666
- }
2667
-
2668
- };
2669
- GUI.toggleHide = function () {
2670
-
2671
- hide = ! hide;
2672
- Common.each( hideableGuis, function ( gui ) {
2673
-
2674
- gui.domElement.style.display = hide ? 'none' : '';
2675
-
2676
- } );
2677
-
2678
- };
2679
- GUI.CLASS_AUTO_PLACE = 'a';
2680
- GUI.CLASS_AUTO_PLACE_CONTAINER = 'ac';
2681
- GUI.CLASS_MAIN = 'main';
2682
- GUI.CLASS_CONTROLLER_ROW = 'cr';
2683
- GUI.CLASS_TOO_TALL = 'taller-than-window';
2684
- GUI.CLASS_CLOSED = 'closed';
2685
- GUI.CLASS_CLOSE_BUTTON = 'close-button';
2686
- GUI.CLASS_CLOSE_TOP = 'close-top';
2687
- GUI.CLASS_CLOSE_BOTTOM = 'close-bottom';
2688
- GUI.CLASS_DRAG = 'drag';
2689
- GUI.DEFAULT_WIDTH = 245;
2690
- GUI.TEXT_CLOSED = 'Close Controls';
2691
- GUI.TEXT_OPEN = 'Open Controls';
2692
- GUI._keydownHandler = function ( e ) {
2693
-
2694
- if ( document.activeElement.type !== 'text' && ( e.which === HIDE_KEY_CODE || e.keyCode === HIDE_KEY_CODE ) ) {
2695
-
2696
- GUI.toggleHide();
2697
-
2698
- }
2699
-
2700
- };
2701
- dom.bind( window, 'keydown', GUI._keydownHandler, false );
2702
- Common.extend( GUI.prototype,
2703
- {
2704
- add: function add( object, property ) {
2705
-
2706
- return _add( this, object, property, {
2707
- factoryArgs: Array.prototype.slice.call( arguments, 2 )
2708
- } );
2709
-
2710
- },
2711
- addColor: function addColor( object, property ) {
2712
-
2713
- return _add( this, object, property, {
2714
- color: true
2715
- } );
2716
-
2717
- },
2718
- remove: function remove( controller ) {
2719
-
2720
- this.__ul.removeChild( controller.__li );
2721
- this.__controllers.splice( this.__controllers.indexOf( controller ), 1 );
2722
- var _this = this;
2723
- Common.defer( function () {
2724
-
2725
- _this.onResize();
2726
-
2727
- } );
2728
-
2729
- },
2730
- destroy: function destroy() {
2731
-
2732
- if ( this.parent ) {
2733
-
2734
- throw new Error( 'Only the root GUI should be removed with .destroy(). ' + 'For subfolders, use gui.removeFolder(folder) instead.' );
2735
-
2736
- }
2737
- if ( this.autoPlace ) {
2738
-
2739
- autoPlaceContainer.removeChild( this.domElement );
2740
-
2741
- }
2742
- var _this = this;
2743
- Common.each( this.__folders, function ( subfolder ) {
2744
-
2745
- _this.removeFolder( subfolder );
2746
-
2747
- } );
2748
- dom.unbind( window, 'keydown', GUI._keydownHandler, false );
2749
- removeListeners( this );
2750
-
2751
- },
2752
- addFolder: function addFolder( name ) {
2753
-
2754
- if ( this.__folders[ name ] !== undefined ) {
2755
-
2756
- throw new Error( 'You already have a folder in this GUI by the' + ' name "' + name + '"' );
2757
-
2758
- }
2759
- var newGuiParams = { name: name, parent: this };
2760
- newGuiParams.autoPlace = this.autoPlace;
2761
- if ( this.load &&
2762
- this.load.folders &&
2763
- this.load.folders[ name ] ) {
2764
-
2765
- newGuiParams.closed = this.load.folders[ name ].closed;
2766
- newGuiParams.load = this.load.folders[ name ];
2767
-
2768
- }
2769
- var gui = new GUI( newGuiParams );
2770
- this.__folders[ name ] = gui;
2771
- var li = addRow( this, gui.domElement );
2772
- dom.addClass( li, 'folder' );
2773
- return gui;
2774
-
2775
- },
2776
- removeFolder: function removeFolder( folder ) {
2777
-
2778
- this.__ul.removeChild( folder.domElement.parentElement );
2779
- delete this.__folders[ folder.name ];
2780
- if ( this.load &&
2781
- this.load.folders &&
2782
- this.load.folders[ folder.name ] ) {
2783
-
2784
- delete this.load.folders[ folder.name ];
2785
-
2786
- }
2787
- removeListeners( folder );
2788
- var _this = this;
2789
- Common.each( folder.__folders, function ( subfolder ) {
2790
-
2791
- folder.removeFolder( subfolder );
2792
-
2793
- } );
2794
- Common.defer( function () {
2795
-
2796
- _this.onResize();
2797
-
2798
- } );
2799
-
2800
- },
2801
- open: function open() {
2802
-
2803
- this.closed = false;
2804
-
2805
- },
2806
- close: function close() {
2807
-
2808
- this.closed = true;
2809
-
2810
- },
2811
- hide: function hide() {
2812
-
2813
- this.domElement.style.display = 'none';
2814
-
2815
- },
2816
- show: function show() {
2817
-
2818
- this.domElement.style.display = '';
2819
-
2820
- },
2821
- onResize: function onResize() {
2822
-
2823
- var root = this.getRoot();
2824
- if ( root.scrollable ) {
2825
-
2826
- var top = dom.getOffset( root.__ul ).top;
2827
- var h = 0;
2828
- Common.each( root.__ul.childNodes, function ( node ) {
2829
-
2830
- if ( ! ( root.autoPlace && node === root.__save_row ) ) {
2831
-
2832
- h += dom.getHeight( node );
2833
-
2834
- }
2835
-
2836
- } );
2837
- if ( window.innerHeight - top - CLOSE_BUTTON_HEIGHT < h ) {
2838
-
2839
- dom.addClass( root.domElement, GUI.CLASS_TOO_TALL );
2840
- root.__ul.style.height = window.innerHeight - top - CLOSE_BUTTON_HEIGHT + 'px';
2841
-
2842
- } else {
2843
-
2844
- dom.removeClass( root.domElement, GUI.CLASS_TOO_TALL );
2845
- root.__ul.style.height = 'auto';
2846
-
2847
- }
2848
-
2849
- }
2850
- if ( root.__resize_handle ) {
2851
-
2852
- Common.defer( function () {
2853
-
2854
- root.__resize_handle.style.height = root.__ul.offsetHeight + 'px';
2855
-
2856
- } );
2857
-
2858
- }
2859
- if ( root.__closeButton ) {
2860
-
2861
- root.__closeButton.style.width = root.width + 'px';
2862
-
2863
- }
2864
-
2865
- },
2866
- onResizeDebounced: Common.debounce( function () {
2867
-
2868
- this.onResize();
2869
-
2870
- }, 50 ),
2871
- remember: function remember() {
2872
-
2873
- if ( Common.isUndefined( SAVE_DIALOGUE ) ) {
2874
-
2875
- SAVE_DIALOGUE = new CenteredDiv();
2876
- SAVE_DIALOGUE.domElement.innerHTML = saveDialogContents;
2877
-
2878
- }
2879
- if ( this.parent ) {
2880
-
2881
- throw new Error( 'You can only call remember on a top level GUI.' );
2882
-
2883
- }
2884
- var _this = this;
2885
- Common.each( Array.prototype.slice.call( arguments ), function ( object ) {
2886
-
2887
- if ( _this.__rememberedObjects.length === 0 ) {
2888
-
2889
- addSaveMenu( _this );
2890
-
2891
- }
2892
- if ( _this.__rememberedObjects.indexOf( object ) === - 1 ) {
2893
-
2894
- _this.__rememberedObjects.push( object );
2895
-
2896
- }
2897
-
2898
- } );
2899
- if ( this.autoPlace ) {
2900
-
2901
- setWidth( this, this.width );
2902
-
2903
- }
2904
-
2905
- },
2906
- getRoot: function getRoot() {
2907
-
2908
- var gui = this;
2909
- while ( gui.parent ) {
2910
-
2911
- gui = gui.parent;
2912
-
2913
- }
2914
- return gui;
2915
-
2916
- },
2917
- getSaveObject: function getSaveObject() {
2918
-
2919
- var toReturn = this.load;
2920
- toReturn.closed = this.closed;
2921
- if ( this.__rememberedObjects.length > 0 ) {
2922
-
2923
- toReturn.preset = this.preset;
2924
- if ( ! toReturn.remembered ) {
2925
-
2926
- toReturn.remembered = {};
2927
-
2928
- }
2929
- toReturn.remembered[ this.preset ] = getCurrentPreset( this );
2930
-
2931
- }
2932
- toReturn.folders = {};
2933
- Common.each( this.__folders, function ( element, key ) {
2934
-
2935
- toReturn.folders[ key ] = element.getSaveObject();
2936
-
2937
- } );
2938
- return toReturn;
2939
-
2940
- },
2941
- save: function save() {
2942
-
2943
- if ( ! this.load.remembered ) {
2944
-
2945
- this.load.remembered = {};
2946
-
2947
- }
2948
- this.load.remembered[ this.preset ] = getCurrentPreset( this );
2949
- markPresetModified( this, false );
2950
- this.saveToLocalStorageIfPossible();
2951
-
2952
- },
2953
- saveAs: function saveAs( presetName ) {
2954
-
2955
- if ( ! this.load.remembered ) {
2956
-
2957
- this.load.remembered = {};
2958
- this.load.remembered[ DEFAULT_DEFAULT_PRESET_NAME ] = getCurrentPreset( this, true );
2959
-
2960
- }
2961
- this.load.remembered[ presetName ] = getCurrentPreset( this );
2962
- this.preset = presetName;
2963
- addPresetOption( this, presetName, true );
2964
- this.saveToLocalStorageIfPossible();
2965
-
2966
- },
2967
- revert: function revert( gui ) {
2968
-
2969
- Common.each( this.__controllers, function ( controller ) {
2970
-
2971
- if ( ! this.getRoot().load.remembered ) {
2972
-
2973
- controller.setValue( controller.initialValue );
2974
-
2975
- } else {
2976
-
2977
- recallSavedValue( gui || this.getRoot(), controller );
2978
-
2979
- }
2980
- if ( controller.__onFinishChange ) {
2981
-
2982
- controller.__onFinishChange.call( controller, controller.getValue() );
2983
-
2984
- }
2985
-
2986
- }, this );
2987
- Common.each( this.__folders, function ( folder ) {
2988
-
2989
- folder.revert( folder );
2990
-
2991
- } );
2992
- if ( ! gui ) {
2993
-
2994
- markPresetModified( this.getRoot(), false );
2995
-
2996
- }
2997
-
2998
- },
2999
- listen: function listen( controller ) {
3000
-
3001
- var init = this.__listening.length === 0;
3002
- this.__listening.push( controller );
3003
- if ( init ) {
3004
-
3005
- updateDisplays( this.__listening );
3006
-
3007
- }
3008
-
3009
- },
3010
- updateDisplay: function updateDisplay() {
3011
-
3012
- Common.each( this.__controllers, function ( controller ) {
3013
-
3014
- controller.updateDisplay();
3015
-
3016
- } );
3017
- Common.each( this.__folders, function ( folder ) {
3018
-
3019
- folder.updateDisplay();
3020
-
3021
- } );
3022
-
3023
- }
3024
- } );
3025
- function addRow( gui, newDom, liBefore ) {
3026
-
3027
- var li = document.createElement( 'li' );
3028
- if ( newDom ) {
3029
-
3030
- li.appendChild( newDom );
3031
-
3032
- }
3033
- if ( liBefore ) {
3034
-
3035
- gui.__ul.insertBefore( li, liBefore );
3036
-
3037
- } else {
3038
-
3039
- gui.__ul.appendChild( li );
3040
-
3041
- }
3042
- gui.onResize();
3043
- return li;
3044
-
3045
- }
3046
- function removeListeners( gui ) {
3047
-
3048
- dom.unbind( window, 'resize', gui.__resizeHandler );
3049
- if ( gui.saveToLocalStorageIfPossible ) {
3050
-
3051
- dom.unbind( window, 'unload', gui.saveToLocalStorageIfPossible );
3052
-
3053
- }
3054
-
3055
- }
3056
- function markPresetModified( gui, modified ) {
3057
-
3058
- var opt = gui.__preset_select[ gui.__preset_select.selectedIndex ];
3059
- if ( modified ) {
3060
-
3061
- opt.innerHTML = opt.value + '*';
3062
-
3063
- } else {
3064
-
3065
- opt.innerHTML = opt.value;
3066
-
3067
- }
3068
-
3069
- }
3070
- function augmentController( gui, li, controller ) {
3071
-
3072
- controller.__li = li;
3073
- controller.__gui = gui;
3074
- Common.extend( controller, {
3075
- options: function options( _options ) {
3076
-
3077
- if ( arguments.length > 1 ) {
3078
-
3079
- var nextSibling = controller.__li.nextElementSibling;
3080
- controller.remove();
3081
- return _add( gui, controller.object, controller.property, {
3082
- before: nextSibling,
3083
- factoryArgs: [ Common.toArray( arguments ) ]
3084
- } );
3085
-
3086
- }
3087
- if ( Common.isArray( _options ) || Common.isObject( _options ) ) {
3088
-
3089
- var _nextSibling = controller.__li.nextElementSibling;
3090
- controller.remove();
3091
- return _add( gui, controller.object, controller.property, {
3092
- before: _nextSibling,
3093
- factoryArgs: [ _options ]
3094
- } );
3095
-
3096
- }
3097
-
3098
- },
3099
- name: function name( _name ) {
3100
-
3101
- controller.__li.firstElementChild.firstElementChild.innerHTML = _name;
3102
- return controller;
3103
-
3104
- },
3105
- listen: function listen() {
3106
-
3107
- controller.__gui.listen( controller );
3108
- return controller;
3109
-
3110
- },
3111
- remove: function remove() {
3112
-
3113
- controller.__gui.remove( controller );
3114
- return controller;
3115
-
3116
- }
3117
- } );
3118
- if ( controller instanceof NumberControllerSlider ) {
3119
-
3120
- var box = new NumberControllerBox( controller.object, controller.property, { min: controller.__min, max: controller.__max, step: controller.__step } );
3121
- Common.each( [ 'updateDisplay', 'onChange', 'onFinishChange', 'step', 'min', 'max' ], function ( method ) {
3122
-
3123
- var pc = controller[ method ];
3124
- var pb = box[ method ];
3125
- controller[ method ] = box[ method ] = function () {
3126
-
3127
- var args = Array.prototype.slice.call( arguments );
3128
- pb.apply( box, args );
3129
- return pc.apply( controller, args );
3130
-
3131
- };
3132
-
3133
- } );
3134
- dom.addClass( li, 'has-slider' );
3135
- controller.domElement.insertBefore( box.domElement, controller.domElement.firstElementChild );
3136
-
3137
- } else if ( controller instanceof NumberControllerBox ) {
3138
-
3139
- var r = function r( returned ) {
3140
-
3141
- if ( Common.isNumber( controller.__min ) && Common.isNumber( controller.__max ) ) {
3142
-
3143
- var oldName = controller.__li.firstElementChild.firstElementChild.innerHTML;
3144
- var wasListening = controller.__gui.__listening.indexOf( controller ) > - 1;
3145
- controller.remove();
3146
- var newController = _add( gui, controller.object, controller.property, {
3147
- before: controller.__li.nextElementSibling,
3148
- factoryArgs: [ controller.__min, controller.__max, controller.__step ]
3149
- } );
3150
- newController.name( oldName );
3151
- if ( wasListening ) newController.listen();
3152
- return newController;
3153
-
3154
- }
3155
- return returned;
3156
-
3157
- };
3158
- controller.min = Common.compose( r, controller.min );
3159
- controller.max = Common.compose( r, controller.max );
3160
-
3161
- } else if ( controller instanceof BooleanController ) {
3162
-
3163
- dom.bind( li, 'click', function () {
3164
-
3165
- dom.fakeEvent( controller.__checkbox, 'click' );
3166
-
3167
- } );
3168
- dom.bind( controller.__checkbox, 'click', function ( e ) {
3169
-
3170
- e.stopPropagation();
3171
-
3172
- } );
3173
-
3174
- } else if ( controller instanceof FunctionController ) {
3175
-
3176
- dom.bind( li, 'click', function () {
3177
-
3178
- dom.fakeEvent( controller.__button, 'click' );
3179
-
3180
- } );
3181
- dom.bind( li, 'mouseover', function () {
3182
-
3183
- dom.addClass( controller.__button, 'hover' );
3184
-
3185
- } );
3186
- dom.bind( li, 'mouseout', function () {
3187
-
3188
- dom.removeClass( controller.__button, 'hover' );
3189
-
3190
- } );
3191
-
3192
- } else if ( controller instanceof ColorController ) {
3193
-
3194
- dom.addClass( li, 'color' );
3195
- controller.updateDisplay = Common.compose( function ( val ) {
3196
-
3197
- li.style.borderLeftColor = controller.__color.toString();
3198
- return val;
3199
-
3200
- }, controller.updateDisplay );
3201
- controller.updateDisplay();
3202
-
3203
- }
3204
- controller.setValue = Common.compose( function ( val ) {
3205
-
3206
- if ( gui.getRoot().__preset_select && controller.isModified() ) {
3207
-
3208
- markPresetModified( gui.getRoot(), true );
3209
-
3210
- }
3211
- return val;
3212
-
3213
- }, controller.setValue );
3214
-
3215
- }
3216
- function recallSavedValue( gui, controller ) {
3217
-
3218
- var root = gui.getRoot();
3219
- var matchedIndex = root.__rememberedObjects.indexOf( controller.object );
3220
- if ( matchedIndex !== - 1 ) {
3221
-
3222
- var controllerMap = root.__rememberedObjectIndecesToControllers[ matchedIndex ];
3223
- if ( controllerMap === undefined ) {
3224
-
3225
- controllerMap = {};
3226
- root.__rememberedObjectIndecesToControllers[ matchedIndex ] = controllerMap;
3227
-
3228
- }
3229
- controllerMap[ controller.property ] = controller;
3230
- if ( root.load && root.load.remembered ) {
3231
-
3232
- var presetMap = root.load.remembered;
3233
- var preset = void 0;
3234
- if ( presetMap[ gui.preset ] ) {
3235
-
3236
- preset = presetMap[ gui.preset ];
3237
-
3238
- } else if ( presetMap[ DEFAULT_DEFAULT_PRESET_NAME ] ) {
3239
-
3240
- preset = presetMap[ DEFAULT_DEFAULT_PRESET_NAME ];
3241
-
3242
- } else {
3243
-
3244
- return;
3245
-
3246
- }
3247
- if ( preset[ matchedIndex ] && preset[ matchedIndex ][ controller.property ] !== undefined ) {
3248
-
3249
- var value = preset[ matchedIndex ][ controller.property ];
3250
- controller.initialValue = value;
3251
- controller.setValue( value );
3252
-
3253
- }
3254
-
3255
- }
3256
-
3257
- }
3258
-
3259
- }
3260
- function _add( gui, object, property, params ) {
3261
-
3262
- if ( object[ property ] === undefined ) {
3263
-
3264
- throw new Error( 'Object "' + object + '" has no property "' + property + '"' );
3265
-
3266
- }
3267
- var controller = void 0;
3268
- if ( params.color ) {
3269
-
3270
- controller = new ColorController( object, property );
3271
-
3272
- } else {
3273
-
3274
- var factoryArgs = [ object, property ].concat( params.factoryArgs );
3275
- controller = ControllerFactory.apply( gui, factoryArgs );
3276
-
3277
- }
3278
- if ( params.before instanceof Controller ) {
3279
-
3280
- params.before = params.before.__li;
3281
-
3282
- }
3283
- recallSavedValue( gui, controller );
3284
- dom.addClass( controller.domElement, 'c' );
3285
- var name = document.createElement( 'span' );
3286
- dom.addClass( name, 'property-name' );
3287
- name.innerHTML = controller.property;
3288
- var container = document.createElement( 'div' );
3289
- container.appendChild( name );
3290
- container.appendChild( controller.domElement );
3291
- var li = addRow( gui, container, params.before );
3292
- dom.addClass( li, GUI.CLASS_CONTROLLER_ROW );
3293
- if ( controller instanceof ColorController ) {
3294
-
3295
- dom.addClass( li, 'color' );
3296
-
3297
- } else {
3298
-
3299
- dom.addClass( li, _typeof( controller.getValue() ) );
3300
-
3301
- }
3302
- augmentController( gui, li, controller );
3303
- gui.__controllers.push( controller );
3304
- return controller;
3305
-
3306
- }
3307
- function getLocalStorageHash( gui, key ) {
3308
-
3309
- return document.location.href + '.' + key;
3310
-
3311
- }
3312
- function addPresetOption( gui, name, setSelected ) {
3313
-
3314
- var opt = document.createElement( 'option' );
3315
- opt.innerHTML = name;
3316
- opt.value = name;
3317
- gui.__preset_select.appendChild( opt );
3318
- if ( setSelected ) {
3319
-
3320
- gui.__preset_select.selectedIndex = gui.__preset_select.length - 1;
3321
-
3322
- }
3323
-
3324
- }
3325
- function showHideExplain( gui, explain ) {
3326
-
3327
- explain.style.display = gui.useLocalStorage ? 'block' : 'none';
3328
-
3329
- }
3330
- function addSaveMenu( gui ) {
3331
-
3332
- var div = gui.__save_row = document.createElement( 'li' );
3333
- dom.addClass( gui.domElement, 'has-save' );
3334
- gui.__ul.insertBefore( div, gui.__ul.firstChild );
3335
- dom.addClass( div, 'save-row' );
3336
- var gears = document.createElement( 'span' );
3337
- gears.innerHTML = '&nbsp;';
3338
- dom.addClass( gears, 'button gears' );
3339
- var button = document.createElement( 'span' );
3340
- button.innerHTML = 'Save';
3341
- dom.addClass( button, 'button' );
3342
- dom.addClass( button, 'save' );
3343
- var button2 = document.createElement( 'span' );
3344
- button2.innerHTML = 'New';
3345
- dom.addClass( button2, 'button' );
3346
- dom.addClass( button2, 'save-as' );
3347
- var button3 = document.createElement( 'span' );
3348
- button3.innerHTML = 'Revert';
3349
- dom.addClass( button3, 'button' );
3350
- dom.addClass( button3, 'revert' );
3351
- var select = gui.__preset_select = document.createElement( 'select' );
3352
- if ( gui.load && gui.load.remembered ) {
3353
-
3354
- Common.each( gui.load.remembered, function ( value, key ) {
3355
-
3356
- addPresetOption( gui, key, key === gui.preset );
3357
-
3358
- } );
3359
-
3360
- } else {
3361
-
3362
- addPresetOption( gui, DEFAULT_DEFAULT_PRESET_NAME, false );
3363
-
3364
- }
3365
- dom.bind( select, 'change', function () {
3366
-
3367
- for ( var index = 0; index < gui.__preset_select.length; index ++ ) {
3368
-
3369
- gui.__preset_select[ index ].innerHTML = gui.__preset_select[ index ].value;
3370
-
3371
- }
3372
- gui.preset = this.value;
3373
-
3374
- } );
3375
- div.appendChild( select );
3376
- div.appendChild( gears );
3377
- div.appendChild( button );
3378
- div.appendChild( button2 );
3379
- div.appendChild( button3 );
3380
- if ( SUPPORTS_LOCAL_STORAGE ) {
3381
-
3382
- var explain = document.getElementById( 'dg-local-explain' );
3383
- var localStorageCheckBox = document.getElementById( 'dg-local-storage' );
3384
- var saveLocally = document.getElementById( 'dg-save-locally' );
3385
- saveLocally.style.display = 'block';
3386
- if ( localStorage.getItem( getLocalStorageHash( gui, 'isLocal' ) ) === 'true' ) {
3387
-
3388
- localStorageCheckBox.setAttribute( 'checked', 'checked' );
3389
-
3390
- }
3391
- showHideExplain( gui, explain );
3392
- dom.bind( localStorageCheckBox, 'change', function () {
3393
-
3394
- gui.useLocalStorage = ! gui.useLocalStorage;
3395
- showHideExplain( gui, explain );
3396
-
3397
- } );
3398
-
3399
- }
3400
- var newConstructorTextArea = document.getElementById( 'dg-new-constructor' );
3401
- dom.bind( newConstructorTextArea, 'keydown', function ( e ) {
3402
-
3403
- if ( e.metaKey && ( e.which === 67 || e.keyCode === 67 ) ) {
3404
-
3405
- SAVE_DIALOGUE.hide();
3406
-
3407
- }
3408
-
3409
- } );
3410
- dom.bind( gears, 'click', function () {
3411
-
3412
- newConstructorTextArea.innerHTML = JSON.stringify( gui.getSaveObject(), undefined, 2 );
3413
- SAVE_DIALOGUE.show();
3414
- newConstructorTextArea.focus();
3415
- newConstructorTextArea.select();
3416
-
3417
- } );
3418
- dom.bind( button, 'click', function () {
3419
-
3420
- gui.save();
3421
-
3422
- } );
3423
- dom.bind( button2, 'click', function () {
3424
-
3425
- var presetName = prompt( 'Enter a new preset name.' );
3426
- if ( presetName ) {
3427
-
3428
- gui.saveAs( presetName );
3429
-
3430
- }
3431
-
3432
- } );
3433
- dom.bind( button3, 'click', function () {
3434
-
3435
- gui.revert();
3436
-
3437
- } );
3438
-
3439
- }
3440
- function addResizeHandle( gui ) {
3441
-
3442
- var pmouseX = void 0;
3443
- gui.__resize_handle = document.createElement( 'div' );
3444
- Common.extend( gui.__resize_handle.style, {
3445
- width: '6px',
3446
- marginLeft: '-3px',
3447
- height: '200px',
3448
- cursor: 'ew-resize',
3449
- position: 'absolute'
3450
- } );
3451
- function drag( e ) {
3452
-
3453
- e.preventDefault();
3454
- gui.width += pmouseX - e.clientX;
3455
- gui.onResize();
3456
- pmouseX = e.clientX;
3457
- return false;
3458
-
3459
- }
3460
- function dragStop() {
3461
-
3462
- dom.removeClass( gui.__closeButton, GUI.CLASS_DRAG );
3463
- dom.unbind( window, 'mousemove', drag );
3464
- dom.unbind( window, 'mouseup', dragStop );
3465
-
3466
- }
3467
- function dragStart( e ) {
3468
-
3469
- e.preventDefault();
3470
- pmouseX = e.clientX;
3471
- dom.addClass( gui.__closeButton, GUI.CLASS_DRAG );
3472
- dom.bind( window, 'mousemove', drag );
3473
- dom.bind( window, 'mouseup', dragStop );
3474
- return false;
3475
-
3476
- }
3477
- dom.bind( gui.__resize_handle, 'mousedown', dragStart );
3478
- dom.bind( gui.__closeButton, 'mousedown', dragStart );
3479
- gui.domElement.insertBefore( gui.__resize_handle, gui.domElement.firstElementChild );
3480
-
3481
- }
3482
- function setWidth( gui, w ) {
3483
-
3484
- gui.domElement.style.width = w + 'px';
3485
- if ( gui.__save_row && gui.autoPlace ) {
3486
-
3487
- gui.__save_row.style.width = w + 'px';
3488
-
3489
- }
3490
- if ( gui.__closeButton ) {
3491
-
3492
- gui.__closeButton.style.width = w + 'px';
3493
-
3494
- }
3495
-
3496
- }
3497
- function getCurrentPreset( gui, useInitialValues ) {
3498
-
3499
- var toReturn = {};
3500
- Common.each( gui.__rememberedObjects, function ( val, index ) {
3501
-
3502
- var savedValues = {};
3503
- var controllerMap = gui.__rememberedObjectIndecesToControllers[ index ];
3504
- Common.each( controllerMap, function ( controller, property ) {
3505
-
3506
- savedValues[ property ] = useInitialValues ? controller.initialValue : controller.getValue();
3507
-
3508
- } );
3509
- toReturn[ index ] = savedValues;
3510
-
3511
- } );
3512
- return toReturn;
3513
-
3514
- }
3515
- function setPresetSelectIndex( gui ) {
3516
-
3517
- for ( var index = 0; index < gui.__preset_select.length; index ++ ) {
3518
-
3519
- if ( gui.__preset_select[ index ].value === gui.preset ) {
3520
-
3521
- gui.__preset_select.selectedIndex = index;
3522
-
3523
- }
3524
-
3525
- }
3526
-
3527
- }
3528
- function updateDisplays( controllerArray ) {
3529
-
3530
- if ( controllerArray.length !== 0 ) {
3531
-
3532
- requestAnimationFrame$1.call( window, function () {
3533
-
3534
- updateDisplays( controllerArray );
3535
-
3536
- } );
3537
-
3538
- }
3539
- Common.each( controllerArray, function ( c ) {
3540
-
3541
- c.updateDisplay();
3542
-
3543
- } );
3544
-
3545
- }
3546
-
3547
- var color = {
3548
- Color: Color,
3549
- math: ColorMath,
3550
- interpret: interpret
3551
- };
3552
- var controllers = {
3553
- Controller: Controller,
3554
- BooleanController: BooleanController,
3555
- OptionController: OptionController,
3556
- StringController: StringController,
3557
- NumberController: NumberController,
3558
- NumberControllerBox: NumberControllerBox,
3559
- NumberControllerSlider: NumberControllerSlider,
3560
- FunctionController: FunctionController,
3561
- ColorController: ColorController
3562
- };
3563
- var dom$1 = { dom: dom };
3564
- var gui = { GUI: GUI };
3565
- var GUI$1 = GUI;
3566
- var index = {
3567
- color: color,
3568
- controllers: controllers,
3569
- dom: dom$1,
3570
- gui: gui,
3571
- GUI: GUI$1
3572
- };
3573
-
3574
- export { color, controllers, dom$1 as dom, gui, GUI$1 as GUI };
3575
- export default index;