|
|
@@ -950,4 +950,85 @@ THREE.Triangle.getInterpolatedAttribute = function( attr, i1, i2, i3, barycoord,
|
|
|
|
|
|
return target;
|
|
|
|
|
|
+}
|
|
|
+
|
|
|
+let _vector$7 = new THREE.Vector3
|
|
|
+THREE.InterleavedBufferAttribute.prototype.applyNormalMatrix = function(m) {
|
|
|
+
|
|
|
+ for (let i = 0, l = this.count; i < l; i++) {
|
|
|
+
|
|
|
+ _vector$7.fromBufferAttribute(this, i);
|
|
|
+
|
|
|
+ _vector$7.applyNormalMatrix(m);
|
|
|
+
|
|
|
+ this.setXYZ(i, _vector$7.x, _vector$7.y, _vector$7.z);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return this;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+THREE.Color.prototype.getHSV = function() {
|
|
|
+ //or hsb 色相、饱和度、明度(不同于hsl的亮度,只有色相是和hsl一样)代码源于deepseek
|
|
|
+ let r = this.r, g = this.g, b = this.b
|
|
|
+ let max = Math.max(r, g, b);
|
|
|
+ let min = Math.min(r, g, b);
|
|
|
+ let h, s, v = max;
|
|
|
+
|
|
|
+ let d = max - min;
|
|
|
+ s = max === 0 ? 0 : d / max;
|
|
|
+
|
|
|
+ if (max === min) {
|
|
|
+ h = 0;
|
|
|
+ // 无色
|
|
|
+ } else {
|
|
|
+ switch (max) {
|
|
|
+ case r:
|
|
|
+ h = (g - b) / d + (g < b ? 6 : 0);
|
|
|
+ break;
|
|
|
+ case g:
|
|
|
+ h = (b - r) / d + 2;
|
|
|
+ break;
|
|
|
+ case b:
|
|
|
+ h = (r - g) / d + 4;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ h /= 6;
|
|
|
+ }
|
|
|
+
|
|
|
+ return {h: h * 360, s: s * 100, v: v * 100};
|
|
|
+}
|
|
|
+THREE.Color.prototype.setHSV = function( h, s, v ) {
|
|
|
+ h = h % 360;
|
|
|
+ s /= 100;
|
|
|
+ v /= 100;
|
|
|
+
|
|
|
+ let c = v * s;
|
|
|
+ let x = c * (1 - Math.abs((h / 60) % 2 - 1));
|
|
|
+ let m = v - c;
|
|
|
+
|
|
|
+ let r, g, b;
|
|
|
+
|
|
|
+ if (0 <= h && h < 60) {
|
|
|
+ [r,g,b] = [c, x, 0];
|
|
|
+ } else if (60 <= h && h < 120) {
|
|
|
+ [r,g,b] = [x, c, 0];
|
|
|
+ } else if (120 <= h && h < 180) {
|
|
|
+ [r,g,b] = [0, c, x];
|
|
|
+ } else if (180 <= h && h < 240) {
|
|
|
+ [r,g,b] = [0, x, c];
|
|
|
+ } else if (240 <= h && h < 300) {
|
|
|
+ [r,g,b] = [x, 0, c];
|
|
|
+ } else if (300 <= h && h < 360) {
|
|
|
+ [r,g,b] = [c, 0, x];
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.setRGB(r + m, g + m, b + m)
|
|
|
+}
|
|
|
+
|
|
|
+let oldSet = THREE.Color.prototype.set
|
|
|
+THREE.Color.prototype.set = function(){
|
|
|
+ if(arguments.length >= 3)return this.setRGB.apply(this, arguments)
|
|
|
+ return oldSet.apply(this, arguments)
|
|
|
}
|