mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-09-17 17:30:06 +02:00
40 lines
1.0 KiB
JavaScript
Executable File
40 lines
1.0 KiB
JavaScript
Executable File
// Allows updating of multiple THREE.Color objects with the same value
|
|
// Used for face.color -> face.vertexColor[] compatibility layer for non-indexed geometry
|
|
|
|
THREE.MultiColor = function(links) {
|
|
|
|
this.links = links;
|
|
|
|
}
|
|
|
|
THREE.MultiColor.prototype = Object.create( THREE.Color.prototype );
|
|
THREE.MultiColor.prototype.constructor = THREE.MultiColor;
|
|
|
|
THREE.MultiColor.prototype.setAll = function(axis, value) {
|
|
|
|
for (var i = 0, l = this.links.length; i < l; i ++) {
|
|
|
|
this.links[i][axis] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Getters return value from the first linked color
|
|
// Setters set the same value for all linked colors
|
|
Object.defineProperties( THREE.MultiColor.prototype, {
|
|
'r': {
|
|
get: function () { return (this.links[0] ? this.links[0].r : 0); },
|
|
set: function ( v ) { this.setAll('r', v); }
|
|
},
|
|
'g': {
|
|
get: function () { return (this.links[0] ? this.links[0].g : 0); },
|
|
set: function ( v ) { this.setAll('g', v); }
|
|
},
|
|
'b': {
|
|
get: function () { return (this.links[0] ? this.links[0].b : 0); },
|
|
set: function ( v ) { this.setAll('b', v); }
|
|
}
|
|
} );
|
|
|