@yangyongtao/gaea 1.0.3 → 1.1.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 (137) hide show
  1. package/README.md +158 -67
  2. package/package.json +28 -7
  3. package/public/Gaea.apple-touch-icon.png +0 -0
  4. package/public/Gaea.apple-touch-icon.png.import +35 -0
  5. package/public/Gaea.audio.worklet.js +211 -0
  6. package/public/Gaea.html +245 -0
  7. package/public/Gaea.icon.png +0 -0
  8. package/public/Gaea.icon.png.import +35 -0
  9. package/public/Gaea.js +782 -0
  10. package/public/Gaea.png +0 -0
  11. package/public/Gaea.png.import +35 -0
  12. package/public/Gaea.worker.js +1 -0
  13. package/public/GaeaApp.html +275 -0
  14. package/public/GaeaMethods.js +4342 -0
  15. package/public/GaeaModule.html +276 -0
  16. package/public/config.js +76 -0
  17. package/public/constants.js +185 -0
  18. package/public/favicon.ico +0 -0
  19. package/public/image/1.png +0 -0
  20. package/public/image/12-min-min.gif +0 -0
  21. package/public/image/3.png +0 -0
  22. package/public/image/labelImg//345/217/263/350/276/271.png +0 -0
  23. package/public/image/labelImg//345/267/246/350/276/271.png +0 -0
  24. package/public/image/labelImg//346/260/264/344/275/215.png +0 -0
  25. package/public/image/screenIcon//345/205/266/344/273/226.png +0 -0
  26. package/public/image/screenIcon//345/256/211/345/205/250/347/233/221/346/265/213/350/201/232/345/220/210-/347/272/242.png +0 -0
  27. package/public/image/screenIcon//345/256/211/345/205/250/347/233/221/346/265/213/350/201/232/345/220/210-/347/273/277.png +0 -0
  28. package/public/image/screenIcon//346/212/242/351/231/251/345/215/225/344/275/215.png +0 -0
  29. package/public/image/screenIcon//346/226/255/351/235/242.png +0 -0
  30. package/public/image/screenIcon//346/227/240/344/272/272/346/234/272.png +0 -0
  31. package/public/image/screenIcon//346/227/240/344/272/272/346/234/272/345/237/272/345/234/260.png +0 -0
  32. package/public/image/screenIcon//346/260/264/345/272/223/347/253/231.png +0 -0
  33. package/public/image/screenIcon//346/260/264/346/226/207/346/265/213/347/253/231.png +0 -0
  34. package/public/image/screenIcon//346/260/264/351/227/270.png +0 -0
  35. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/346/227/240/346/225/260/346/215/256.png +0 -0
  36. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/346/255/243/345/270/270.png +0 -0
  37. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/350/266/205/344/277/235.png +0 -0
  38. package/public/image/screenIcon//346/262/263/351/201/223/347/253/231-/350/266/205/350/255/246.png +0 -0
  39. package/public/image/screenIcon//346/263/265/347/253/231-/347/201/260.png +0 -0
  40. package/public/image/screenIcon//346/263/265/347/253/231-/347/273/277.png +0 -0
  41. package/public/image/screenIcon//346/265/201/351/207/217/346/265/213/347/253/231.png +0 -0
  42. package/public/image/screenIcon//346/265/267/345/241/230-1/347/272/247.png +0 -0
  43. package/public/image/screenIcon//346/265/267/345/241/230-2/347/272/247.png +0 -0
  44. package/public/image/screenIcon//346/265/267/345/241/230-3/347/272/247.png +0 -0
  45. package/public/image/screenIcon//346/265/267/345/241/230-4/347/272/247.png +0 -0
  46. package/public/image/screenIcon//346/265/267/345/241/230-5/347/272/247.png +0 -0
  47. package/public/image/screenIcon//346/265/267/345/241/230-/346/251/231.png +0 -0
  48. package/public/image/screenIcon//346/265/267/345/241/230-/347/272/242.png +0 -0
  49. package/public/image/screenIcon//346/265/267/345/241/230-/347/273/277.png +0 -0
  50. package/public/image/screenIcon//346/265/267/345/241/230-/350/247/204/346/250/241/344/273/245/344/270/213.png +0 -0
  51. package/public/image/screenIcon//346/265/267/345/241/230-/351/273/204.png +0 -0
  52. package/public/image/screenIcon//346/265/267/345/241/230.png +0 -0
  53. package/public/image/screenIcon//346/275/256/344/275/215.png +0 -0
  54. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/346/227/240/346/225/260/346/215/256.png +0 -0
  55. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/346/255/243/345/270/270.png +0 -0
  56. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/350/266/205/344/277/235.png +0 -0
  57. package/public/image/screenIcon//346/275/256/344/275/215/347/253/231-/350/266/205/350/255/246.png +0 -0
  58. package/public/image/screenIcon//347/211/251/350/265/204/344/273/223/345/272/223.png +0 -0
  59. package/public/image/screenIcon//347/220/203/346/234/272-/345/205/263.png +0 -0
  60. package/public/image/screenIcon//347/220/203/346/234/272-/345/274/200.png +0 -0
  61. package/public/image/screenIcon//347/220/203/346/234/272-/347/272/242.png +0 -0
  62. package/public/image/screenIcon//350/247/206/351/242/221/347/233/221/346/216/247.png +0 -0
  63. package/public/image/screenIcon//351/227/270/351/227/250-/347/201/260.png +0 -0
  64. package/public/image/screenIcon//351/227/270/351/227/250-/347/273/277.png +0 -0
  65. package/public/image/screenIcon//351/230/262/346/264/252/344/273/223/345/272/223.png +0 -0
  66. package/public/image/screenIcon//351/232/220/346/202/243.png +0 -0
  67. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/346/265/205/350/223/235.png +0 -0
  68. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/201/260.png +0 -0
  69. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/262/211.png +0 -0
  70. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/272/242.png +0 -0
  71. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/347/273/277.png +0 -0
  72. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/350/223/235.png +0 -0
  73. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/351/273/204.png +0 -0
  74. package/public/image/screenIcon//351/233/250/351/207/217/347/253/231-/351/273/221.png +0 -0
  75. package/public/image/screenIcon//351/243/216/351/200/237.png +0 -0
  76. package/public/image/screenIcon//351/243/216/351/200/237/346/265/213/347/253/231.png +0 -0
  77. package/public/image//346/260/264/346/226/207.gif +0 -0
  78. package/public/image//350/211/262/345/270/246.png +0 -0
  79. package/public/index.html +22 -0
  80. package/public/index.js +185662 -0
  81. package/public/jsWebControl-1.0.0.min.js +31 -0
  82. package/public/jsencrypt.min.js +1 -0
  83. package/public/math/Box2.js +203 -0
  84. package/public/math/Box3.js +532 -0
  85. package/public/math/Color.js +605 -0
  86. package/public/math/ColorManagement.js +74 -0
  87. package/public/math/Cylindrical.js +61 -0
  88. package/public/math/EngineUtils.js +81 -0
  89. package/public/math/Euler.js +315 -0
  90. package/public/math/Frustum.js +162 -0
  91. package/public/math/Interpolant.js +241 -0
  92. package/public/math/Line3.js +115 -0
  93. package/public/math/MathUtils.js +345 -0
  94. package/public/math/Matrix3.js +365 -0
  95. package/public/math/Matrix4.js +858 -0
  96. package/public/math/Plane.js +205 -0
  97. package/public/math/Quaternion.js +724 -0
  98. package/public/math/Ray.js +493 -0
  99. package/public/math/Sphere.js +243 -0
  100. package/public/math/Spherical.js +86 -0
  101. package/public/math/SphericalHarmonics3.js +243 -0
  102. package/public/math/Triangle.js +299 -0
  103. package/public/math/Vector2.js +464 -0
  104. package/public/math/Vector3.js +715 -0
  105. package/public/math/Vector4.js +644 -0
  106. package/public/math/interpolants/CubicInterpolant.js +151 -0
  107. package/public/math/interpolants/DiscreteInterpolant.js +26 -0
  108. package/public/math/interpolants/LinearInterpolant.js +38 -0
  109. package/public/math/interpolants/QuaternionLinearInterpolant.js +39 -0
  110. package/public/static/Cloud.png +0 -0
  111. package/public/static/Global2.jpg +0 -0
  112. package/public/static/css/main.css +170 -0
  113. package/public/static/geojson//346/265/267/345/241/230.geojson +99 -0
  114. package/public/static/img/loading.gif +0 -0
  115. package/public/static/js/app.js +359 -0
  116. package/public/static/js/appcontroller.js +207 -0
  117. package/public/static/js/dist/game.dev.js +137 -0
  118. package/public/static/js/env.js +74 -0
  119. package/public/static/js/event/event.js +107 -0
  120. package/public/static/js/init.js +8 -0
  121. package/public/static/js/initcloudmorph.js +1 -0
  122. package/public/static/js/log.js +35 -0
  123. package/public/static/js/network/ajax.js +29 -0
  124. package/public/static/js/network/rtcp.js +172 -0
  125. package/public/static/js/network/socket.js +106 -0
  126. package/public/web-control.min.js +2 -0
  127. package/scripts/postinstall.mjs +127 -0
  128. package/src/GaeaMethods.js +68 -405
  129. package/src/components/FlyAlongRoute.vue +1 -0
  130. package/src/components/WeatherControl.vue +2 -0
  131. package/src/directives/vDrag.js +70 -0
  132. package/src/index.js +1 -8
  133. package/src/plugin.js +16 -0
  134. package/src/utils.js +10 -21
  135. package/src/vite-plugin.js +117 -0
  136. package/public/static/1111.res +0 -0
  137. package/src/config.js +0 -40
@@ -0,0 +1,605 @@
1
+ import { clamp, euclideanModulo, lerp } from './MathUtils.js';
2
+ import { ColorManagement, SRGBToLinear, LinearToSRGB } from './ColorManagement.js';
3
+ import { SRGBColorSpace } from '../constants.js';
4
+
5
+ const _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
6
+ 'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
7
+ 'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,
8
+ 'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,
9
+ 'darkgoldenrod': 0xB8860B, 'darkgray': 0xA9A9A9, 'darkgreen': 0x006400, 'darkgrey': 0xA9A9A9, 'darkkhaki': 0xBDB76B, 'darkmagenta': 0x8B008B,
10
+ 'darkolivegreen': 0x556B2F, 'darkorange': 0xFF8C00, 'darkorchid': 0x9932CC, 'darkred': 0x8B0000, 'darksalmon': 0xE9967A, 'darkseagreen': 0x8FBC8F,
11
+ 'darkslateblue': 0x483D8B, 'darkslategray': 0x2F4F4F, 'darkslategrey': 0x2F4F4F, 'darkturquoise': 0x00CED1, 'darkviolet': 0x9400D3,
12
+ 'deeppink': 0xFF1493, 'deepskyblue': 0x00BFFF, 'dimgray': 0x696969, 'dimgrey': 0x696969, 'dodgerblue': 0x1E90FF, 'firebrick': 0xB22222,
13
+ 'floralwhite': 0xFFFAF0, 'forestgreen': 0x228B22, 'fuchsia': 0xFF00FF, 'gainsboro': 0xDCDCDC, 'ghostwhite': 0xF8F8FF, 'gold': 0xFFD700,
14
+ 'goldenrod': 0xDAA520, 'gray': 0x808080, 'green': 0x008000, 'greenyellow': 0xADFF2F, 'grey': 0x808080, 'honeydew': 0xF0FFF0, 'hotpink': 0xFF69B4,
15
+ 'indianred': 0xCD5C5C, 'indigo': 0x4B0082, 'ivory': 0xFFFFF0, 'khaki': 0xF0E68C, 'lavender': 0xE6E6FA, 'lavenderblush': 0xFFF0F5, 'lawngreen': 0x7CFC00,
16
+ 'lemonchiffon': 0xFFFACD, 'lightblue': 0xADD8E6, 'lightcoral': 0xF08080, 'lightcyan': 0xE0FFFF, 'lightgoldenrodyellow': 0xFAFAD2, 'lightgray': 0xD3D3D3,
17
+ 'lightgreen': 0x90EE90, 'lightgrey': 0xD3D3D3, 'lightpink': 0xFFB6C1, 'lightsalmon': 0xFFA07A, 'lightseagreen': 0x20B2AA, 'lightskyblue': 0x87CEFA,
18
+ 'lightslategray': 0x778899, 'lightslategrey': 0x778899, 'lightsteelblue': 0xB0C4DE, 'lightyellow': 0xFFFFE0, 'lime': 0x00FF00, 'limegreen': 0x32CD32,
19
+ 'linen': 0xFAF0E6, 'magenta': 0xFF00FF, 'maroon': 0x800000, 'mediumaquamarine': 0x66CDAA, 'mediumblue': 0x0000CD, 'mediumorchid': 0xBA55D3,
20
+ 'mediumpurple': 0x9370DB, 'mediumseagreen': 0x3CB371, 'mediumslateblue': 0x7B68EE, 'mediumspringgreen': 0x00FA9A, 'mediumturquoise': 0x48D1CC,
21
+ 'mediumvioletred': 0xC71585, 'midnightblue': 0x191970, 'mintcream': 0xF5FFFA, 'mistyrose': 0xFFE4E1, 'moccasin': 0xFFE4B5, 'navajowhite': 0xFFDEAD,
22
+ 'navy': 0x000080, 'oldlace': 0xFDF5E6, 'olive': 0x808000, 'olivedrab': 0x6B8E23, 'orange': 0xFFA500, 'orangered': 0xFF4500, 'orchid': 0xDA70D6,
23
+ 'palegoldenrod': 0xEEE8AA, 'palegreen': 0x98FB98, 'paleturquoise': 0xAFEEEE, 'palevioletred': 0xDB7093, 'papayawhip': 0xFFEFD5, 'peachpuff': 0xFFDAB9,
24
+ 'peru': 0xCD853F, 'pink': 0xFFC0CB, 'plum': 0xDDA0DD, 'powderblue': 0xB0E0E6, 'purple': 0x800080, 'rebeccapurple': 0x663399, 'red': 0xFF0000, 'rosybrown': 0xBC8F8F,
25
+ 'royalblue': 0x4169E1, 'saddlebrown': 0x8B4513, 'salmon': 0xFA8072, 'sandybrown': 0xF4A460, 'seagreen': 0x2E8B57, 'seashell': 0xFFF5EE,
26
+ 'sienna': 0xA0522D, 'silver': 0xC0C0C0, 'skyblue': 0x87CEEB, 'slateblue': 0x6A5ACD, 'slategray': 0x708090, 'slategrey': 0x708090, 'snow': 0xFFFAFA,
27
+ 'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,
28
+ 'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };
29
+
30
+ const _rgb = { r: 0, g: 0, b: 0 };
31
+ const _hslA = { h: 0, s: 0, l: 0 };
32
+ const _hslB = { h: 0, s: 0, l: 0 };
33
+
34
+ function hue2rgb( p, q, t ) {
35
+
36
+ if ( t < 0 ) t += 1;
37
+ if ( t > 1 ) t -= 1;
38
+ if ( t < 1 / 6 ) return p + ( q - p ) * 6 * t;
39
+ if ( t < 1 / 2 ) return q;
40
+ if ( t < 2 / 3 ) return p + ( q - p ) * 6 * ( 2 / 3 - t );
41
+ return p;
42
+
43
+ }
44
+
45
+ function toComponents( source, target ) {
46
+
47
+ target.r = source.r;
48
+ target.g = source.g;
49
+ target.b = source.b;
50
+
51
+ return target;
52
+
53
+ }
54
+
55
+ class Color {
56
+
57
+ constructor( r, g, b ) {
58
+
59
+ this.isColor = true;
60
+
61
+ this.r = 1;
62
+ this.g = 1;
63
+ this.b = 1;
64
+
65
+ if ( g === undefined && b === undefined ) {
66
+
67
+ // r is THREE.Color, hex or string
68
+ return this.set( r );
69
+
70
+ }
71
+
72
+ return this.setRGB( r, g, b );
73
+
74
+ }
75
+
76
+ set( value ) {
77
+
78
+ if ( value && value.isColor ) {
79
+
80
+ this.copy( value );
81
+
82
+ } else if ( typeof value === 'number' ) {
83
+
84
+ this.setHex( value );
85
+
86
+ } else if ( typeof value === 'string' ) {
87
+
88
+ this.setStyle( value );
89
+
90
+ }
91
+
92
+ return this;
93
+
94
+ }
95
+
96
+ setScalar( scalar ) {
97
+
98
+ this.r = scalar;
99
+ this.g = scalar;
100
+ this.b = scalar;
101
+
102
+ return this;
103
+
104
+ }
105
+
106
+ setHex( hex, colorSpace = SRGBColorSpace ) {
107
+
108
+ hex = Math.floor( hex );
109
+
110
+ this.r = ( hex >> 16 & 255 ) / 255;
111
+ this.g = ( hex >> 8 & 255 ) / 255;
112
+ this.b = ( hex & 255 ) / 255;
113
+
114
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
115
+
116
+ return this;
117
+
118
+ }
119
+
120
+ setRGB( r, g, b, colorSpace = ColorManagement.workingColorSpace ) {
121
+
122
+ this.r = r;
123
+ this.g = g;
124
+ this.b = b;
125
+
126
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
127
+
128
+ return this;
129
+
130
+ }
131
+
132
+ setHSL( h, s, l, colorSpace = ColorManagement.workingColorSpace ) {
133
+
134
+ // h,s,l ranges are in 0.0 - 1.0
135
+ h = euclideanModulo( h, 1 );
136
+ s = clamp( s, 0, 1 );
137
+ l = clamp( l, 0, 1 );
138
+
139
+ if ( s === 0 ) {
140
+
141
+ this.r = this.g = this.b = l;
142
+
143
+ } else {
144
+
145
+ const p = l <= 0.5 ? l * ( 1 + s ) : l + s - ( l * s );
146
+ const q = ( 2 * l ) - p;
147
+
148
+ this.r = hue2rgb( q, p, h + 1 / 3 );
149
+ this.g = hue2rgb( q, p, h );
150
+ this.b = hue2rgb( q, p, h - 1 / 3 );
151
+
152
+ }
153
+
154
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
155
+
156
+ return this;
157
+
158
+ }
159
+
160
+ setStyle( style, colorSpace = SRGBColorSpace ) {
161
+
162
+ function handleAlpha( string ) {
163
+
164
+ if ( string === undefined ) return;
165
+
166
+ if ( parseFloat( string ) < 1 ) {
167
+
168
+ console.warn( 'THREE.Color: Alpha component of ' + style + ' will be ignored.' );
169
+
170
+ }
171
+
172
+ }
173
+
174
+
175
+ let m;
176
+
177
+ if ( m = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec( style ) ) {
178
+
179
+ // rgb / hsl
180
+
181
+ let color;
182
+ const name = m[ 1 ];
183
+ const components = m[ 2 ];
184
+
185
+ switch ( name ) {
186
+
187
+ case 'rgb':
188
+ case 'rgba':
189
+
190
+ if ( color = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
191
+
192
+ // rgb(255,0,0) rgba(255,0,0,0.5)
193
+ this.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;
194
+ this.g = Math.min( 255, parseInt( color[ 2 ], 10 ) ) / 255;
195
+ this.b = Math.min( 255, parseInt( color[ 3 ], 10 ) ) / 255;
196
+
197
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
198
+
199
+ handleAlpha( color[ 4 ] );
200
+
201
+ return this;
202
+
203
+ }
204
+
205
+ if ( color = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
206
+
207
+ // rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)
208
+ this.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;
209
+ this.g = Math.min( 100, parseInt( color[ 2 ], 10 ) ) / 100;
210
+ this.b = Math.min( 100, parseInt( color[ 3 ], 10 ) ) / 100;
211
+
212
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
213
+
214
+ handleAlpha( color[ 4 ] );
215
+
216
+ return this;
217
+
218
+ }
219
+
220
+ break;
221
+
222
+ case 'hsl':
223
+ case 'hsla':
224
+
225
+ if ( color = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec( components ) ) {
226
+
227
+ // hsl(120,50%,50%) hsla(120,50%,50%,0.5)
228
+ const h = parseFloat( color[ 1 ] ) / 360;
229
+ const s = parseFloat( color[ 2 ] ) / 100;
230
+ const l = parseFloat( color[ 3 ] ) / 100;
231
+
232
+ handleAlpha( color[ 4 ] );
233
+
234
+ return this.setHSL( h, s, l, colorSpace );
235
+
236
+ }
237
+
238
+ break;
239
+
240
+ }
241
+
242
+ } else if ( m = /^\#([A-Fa-f\d]+)$/.exec( style ) ) {
243
+
244
+ // hex color
245
+
246
+ const hex = m[ 1 ];
247
+ const size = hex.length;
248
+
249
+ if ( size === 3 ) {
250
+
251
+ // #ff0
252
+ this.r = parseInt( hex.charAt( 0 ) + hex.charAt( 0 ), 16 ) / 255;
253
+ this.g = parseInt( hex.charAt( 1 ) + hex.charAt( 1 ), 16 ) / 255;
254
+ this.b = parseInt( hex.charAt( 2 ) + hex.charAt( 2 ), 16 ) / 255;
255
+
256
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
257
+
258
+ return this;
259
+
260
+ } else if ( size === 6 ) {
261
+
262
+ // #ff0000
263
+ this.r = parseInt( hex.charAt( 0 ) + hex.charAt( 1 ), 16 ) / 255;
264
+ this.g = parseInt( hex.charAt( 2 ) + hex.charAt( 3 ), 16 ) / 255;
265
+ this.b = parseInt( hex.charAt( 4 ) + hex.charAt( 5 ), 16 ) / 255;
266
+
267
+ ColorManagement.toWorkingColorSpace( this, colorSpace );
268
+
269
+ return this;
270
+
271
+ }
272
+
273
+ }
274
+
275
+ if ( style && style.length > 0 ) {
276
+
277
+ return this.setColorName( style, colorSpace );
278
+
279
+ }
280
+
281
+ return this;
282
+
283
+ }
284
+
285
+ setColorName( style, colorSpace = SRGBColorSpace ) {
286
+
287
+ // color keywords
288
+ const hex = _colorKeywords[ style.toLowerCase() ];
289
+
290
+ if ( hex !== undefined ) {
291
+
292
+ // red
293
+ this.setHex( hex, colorSpace );
294
+
295
+ } else {
296
+
297
+ // unknown color
298
+ console.warn( 'THREE.Color: Unknown color ' + style );
299
+
300
+ }
301
+
302
+ return this;
303
+
304
+ }
305
+
306
+ clone() {
307
+
308
+ return new this.constructor( this.r, this.g, this.b );
309
+
310
+ }
311
+
312
+ copy( color ) {
313
+
314
+ this.r = color.r;
315
+ this.g = color.g;
316
+ this.b = color.b;
317
+
318
+ return this;
319
+
320
+ }
321
+
322
+ copySRGBToLinear( color ) {
323
+
324
+ this.r = SRGBToLinear( color.r );
325
+ this.g = SRGBToLinear( color.g );
326
+ this.b = SRGBToLinear( color.b );
327
+
328
+ return this;
329
+
330
+ }
331
+
332
+ copyLinearToSRGB( color ) {
333
+
334
+ this.r = LinearToSRGB( color.r );
335
+ this.g = LinearToSRGB( color.g );
336
+ this.b = LinearToSRGB( color.b );
337
+
338
+ return this;
339
+
340
+ }
341
+
342
+ convertSRGBToLinear() {
343
+
344
+ this.copySRGBToLinear( this );
345
+
346
+ return this;
347
+
348
+ }
349
+
350
+ convertLinearToSRGB() {
351
+
352
+ this.copyLinearToSRGB( this );
353
+
354
+ return this;
355
+
356
+ }
357
+
358
+ getHex( colorSpace = SRGBColorSpace ) {
359
+
360
+ ColorManagement.fromWorkingColorSpace( toComponents( this, _rgb ), colorSpace );
361
+
362
+ return clamp( _rgb.r * 255, 0, 255 ) << 16 ^ clamp( _rgb.g * 255, 0, 255 ) << 8 ^ clamp( _rgb.b * 255, 0, 255 ) << 0;
363
+
364
+ }
365
+
366
+ getHexString( colorSpace = SRGBColorSpace ) {
367
+
368
+ return ( '000000' + this.getHex( colorSpace ).toString( 16 ) ).slice( - 6 );
369
+
370
+ }
371
+
372
+ getHSL( target, colorSpace = ColorManagement.workingColorSpace ) {
373
+
374
+ // h,s,l ranges are in 0.0 - 1.0
375
+
376
+ ColorManagement.fromWorkingColorSpace( toComponents( this, _rgb ), colorSpace );
377
+
378
+ const r = _rgb.r, g = _rgb.g, b = _rgb.b;
379
+
380
+ const max = Math.max( r, g, b );
381
+ const min = Math.min( r, g, b );
382
+
383
+ let hue, saturation;
384
+ const lightness = ( min + max ) / 2.0;
385
+
386
+ if ( min === max ) {
387
+
388
+ hue = 0;
389
+ saturation = 0;
390
+
391
+ } else {
392
+
393
+ const delta = max - min;
394
+
395
+ saturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min );
396
+
397
+ switch ( max ) {
398
+
399
+ case r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break;
400
+ case g: hue = ( b - r ) / delta + 2; break;
401
+ case b: hue = ( r - g ) / delta + 4; break;
402
+
403
+ }
404
+
405
+ hue /= 6;
406
+
407
+ }
408
+
409
+ target.h = hue;
410
+ target.s = saturation;
411
+ target.l = lightness;
412
+
413
+ return target;
414
+
415
+ }
416
+
417
+ getRGB( target, colorSpace = ColorManagement.workingColorSpace ) {
418
+
419
+ ColorManagement.fromWorkingColorSpace( toComponents( this, _rgb ), colorSpace );
420
+
421
+ target.r = _rgb.r;
422
+ target.g = _rgb.g;
423
+ target.b = _rgb.b;
424
+
425
+ return target;
426
+
427
+ }
428
+
429
+ getStyle( colorSpace = SRGBColorSpace ) {
430
+
431
+ ColorManagement.fromWorkingColorSpace( toComponents( this, _rgb ), colorSpace );
432
+
433
+ if ( colorSpace !== SRGBColorSpace ) {
434
+
435
+ // Requires CSS Color Module Level 4 (https://www.w3.org/TR/css-color-4/).
436
+ return `color(${ colorSpace } ${ _rgb.r } ${ _rgb.g } ${ _rgb.b })`;
437
+
438
+ }
439
+
440
+ return `rgb(${( _rgb.r * 255 ) | 0},${( _rgb.g * 255 ) | 0},${( _rgb.b * 255 ) | 0})`;
441
+
442
+ }
443
+
444
+ offsetHSL( h, s, l ) {
445
+
446
+ this.getHSL( _hslA );
447
+
448
+ _hslA.h += h; _hslA.s += s; _hslA.l += l;
449
+
450
+ this.setHSL( _hslA.h, _hslA.s, _hslA.l );
451
+
452
+ return this;
453
+
454
+ }
455
+
456
+ add( color ) {
457
+
458
+ this.r += color.r;
459
+ this.g += color.g;
460
+ this.b += color.b;
461
+
462
+ return this;
463
+
464
+ }
465
+
466
+ addColors( color1, color2 ) {
467
+
468
+ this.r = color1.r + color2.r;
469
+ this.g = color1.g + color2.g;
470
+ this.b = color1.b + color2.b;
471
+
472
+ return this;
473
+
474
+ }
475
+
476
+ addScalar( s ) {
477
+
478
+ this.r += s;
479
+ this.g += s;
480
+ this.b += s;
481
+
482
+ return this;
483
+
484
+ }
485
+
486
+ sub( color ) {
487
+
488
+ this.r = Math.max( 0, this.r - color.r );
489
+ this.g = Math.max( 0, this.g - color.g );
490
+ this.b = Math.max( 0, this.b - color.b );
491
+
492
+ return this;
493
+
494
+ }
495
+
496
+ multiply( color ) {
497
+
498
+ this.r *= color.r;
499
+ this.g *= color.g;
500
+ this.b *= color.b;
501
+
502
+ return this;
503
+
504
+ }
505
+
506
+ multiplyScalar( s ) {
507
+
508
+ this.r *= s;
509
+ this.g *= s;
510
+ this.b *= s;
511
+
512
+ return this;
513
+
514
+ }
515
+
516
+ lerp( color, alpha ) {
517
+
518
+ this.r += ( color.r - this.r ) * alpha;
519
+ this.g += ( color.g - this.g ) * alpha;
520
+ this.b += ( color.b - this.b ) * alpha;
521
+
522
+ return this;
523
+
524
+ }
525
+
526
+ lerpColors( color1, color2, alpha ) {
527
+
528
+ this.r = color1.r + ( color2.r - color1.r ) * alpha;
529
+ this.g = color1.g + ( color2.g - color1.g ) * alpha;
530
+ this.b = color1.b + ( color2.b - color1.b ) * alpha;
531
+
532
+ return this;
533
+
534
+ }
535
+
536
+ lerpHSL( color, alpha ) {
537
+
538
+ this.getHSL( _hslA );
539
+ color.getHSL( _hslB );
540
+
541
+ const h = lerp( _hslA.h, _hslB.h, alpha );
542
+ const s = lerp( _hslA.s, _hslB.s, alpha );
543
+ const l = lerp( _hslA.l, _hslB.l, alpha );
544
+
545
+ this.setHSL( h, s, l );
546
+
547
+ return this;
548
+
549
+ }
550
+
551
+ equals( c ) {
552
+
553
+ return ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b );
554
+
555
+ }
556
+
557
+ fromArray( array, offset = 0 ) {
558
+
559
+ this.r = array[ offset ];
560
+ this.g = array[ offset + 1 ];
561
+ this.b = array[ offset + 2 ];
562
+
563
+ return this;
564
+
565
+ }
566
+
567
+ toArray( array = [], offset = 0 ) {
568
+
569
+ array[ offset ] = this.r;
570
+ array[ offset + 1 ] = this.g;
571
+ array[ offset + 2 ] = this.b;
572
+
573
+ return array;
574
+
575
+ }
576
+
577
+ fromBufferAttribute( attribute, index ) {
578
+
579
+ this.r = attribute.getX( index );
580
+ this.g = attribute.getY( index );
581
+ this.b = attribute.getZ( index );
582
+
583
+ return this;
584
+
585
+ }
586
+
587
+ toJSON() {
588
+
589
+ return this.getHex();
590
+
591
+ }
592
+
593
+ *[ Symbol.iterator ]() {
594
+
595
+ yield this.r;
596
+ yield this.g;
597
+ yield this.b;
598
+
599
+ }
600
+
601
+ }
602
+
603
+ Color.NAMES = _colorKeywords;
604
+
605
+ export { Color, SRGBToLinear };
@@ -0,0 +1,74 @@
1
+ import { SRGBColorSpace, LinearSRGBColorSpace } from '../constants.js';
2
+
3
+ export function SRGBToLinear( c ) {
4
+
5
+ return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
6
+
7
+ }
8
+
9
+ export function LinearToSRGB( c ) {
10
+
11
+ return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;
12
+
13
+ }
14
+
15
+ // JavaScript RGB-to-RGB transforms, defined as
16
+ // FN[InputColorSpace][OutputColorSpace] callback functions.
17
+ const FN = {
18
+ [ SRGBColorSpace ]: { [ LinearSRGBColorSpace ]: SRGBToLinear },
19
+ [ LinearSRGBColorSpace ]: { [ SRGBColorSpace ]: LinearToSRGB },
20
+ };
21
+
22
+ export const ColorManagement = {
23
+
24
+ legacyMode: true,
25
+
26
+ get workingColorSpace() {
27
+
28
+ return LinearSRGBColorSpace;
29
+
30
+ },
31
+
32
+ set workingColorSpace( colorSpace ) {
33
+
34
+ console.warn( 'THREE.ColorManagement: .workingColorSpace is readonly.' );
35
+
36
+ },
37
+
38
+ convert: function ( color, sourceColorSpace, targetColorSpace ) {
39
+
40
+ if ( this.legacyMode || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {
41
+
42
+ return color;
43
+
44
+ }
45
+
46
+ if ( FN[ sourceColorSpace ] && FN[ sourceColorSpace ][ targetColorSpace ] !== undefined ) {
47
+
48
+ const fn = FN[ sourceColorSpace ][ targetColorSpace ];
49
+
50
+ color.r = fn( color.r );
51
+ color.g = fn( color.g );
52
+ color.b = fn( color.b );
53
+
54
+ return color;
55
+
56
+ }
57
+
58
+ throw new Error( 'Unsupported color space conversion.' );
59
+
60
+ },
61
+
62
+ fromWorkingColorSpace: function ( color, targetColorSpace ) {
63
+
64
+ return this.convert( color, this.workingColorSpace, targetColorSpace );
65
+
66
+ },
67
+
68
+ toWorkingColorSpace: function ( color, sourceColorSpace ) {
69
+
70
+ return this.convert( color, sourceColorSpace, this.workingColorSpace );
71
+
72
+ },
73
+
74
+ };