vim-web 0.5.0-dev.5 → 0.5.0-dev.7
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.
- package/dist/types/core-viewers/ultra/colorManager.d.ts +4 -4
- package/dist/types/core-viewers/ultra/element3d.d.ts +4 -4
- package/dist/types/core-viewers/ultra/index.d.ts +1 -1
- package/dist/types/core-viewers/ultra/remoteColor.d.ts +3 -23
- package/dist/types/core-viewers/ultra/renderer.d.ts +14 -11
- package/dist/types/core-viewers/ultra/rpcTypes.d.ts +3 -0
- package/dist/types/core-viewers/ultra/rpcUtils.d.ts +8 -0
- package/dist/types/core-viewers/ultra/vim.d.ts +4 -5
- package/dist/types/utils/validation.d.ts +4 -4
- package/dist/vim-web.iife.js +235 -245
- package/dist/vim-web.iife.js.map +1 -1
- package/dist/vim-web.js +235 -245
- package/dist/vim-web.js.map +1 -1
- package/package.json +1 -1
package/dist/vim-web.js
CHANGED
|
@@ -50825,6 +50825,164 @@ function isFilePathOrUri(input) {
|
|
|
50825
50825
|
}
|
|
50826
50826
|
return true;
|
|
50827
50827
|
}
|
|
50828
|
+
class Segment {
|
|
50829
|
+
constructor(origin = new Vector3(), target = new Vector3()) {
|
|
50830
|
+
__publicField(this, "origin");
|
|
50831
|
+
__publicField(this, "target");
|
|
50832
|
+
this.origin = origin;
|
|
50833
|
+
this.target = target;
|
|
50834
|
+
}
|
|
50835
|
+
static fromArray(array) {
|
|
50836
|
+
return new Segment(
|
|
50837
|
+
new Vector3(array[0], array[1], array[2]),
|
|
50838
|
+
new Vector3(array[3], array[4], array[5])
|
|
50839
|
+
);
|
|
50840
|
+
}
|
|
50841
|
+
toArray() {
|
|
50842
|
+
return [this.origin.x, this.origin.y, this.origin.z, this.target.x, this.target.y, this.target.z];
|
|
50843
|
+
}
|
|
50844
|
+
isValid() {
|
|
50845
|
+
return !this.origin.equals(this.target);
|
|
50846
|
+
}
|
|
50847
|
+
equals(segment) {
|
|
50848
|
+
return this.origin.equals(segment.origin) && this.target.equals(segment.target);
|
|
50849
|
+
}
|
|
50850
|
+
}
|
|
50851
|
+
class RGBA {
|
|
50852
|
+
constructor(r, g, b, a = 1) {
|
|
50853
|
+
__publicField(this, "r");
|
|
50854
|
+
__publicField(this, "g");
|
|
50855
|
+
__publicField(this, "b");
|
|
50856
|
+
__publicField(this, "a");
|
|
50857
|
+
this.r = r;
|
|
50858
|
+
this.g = g;
|
|
50859
|
+
this.b = b;
|
|
50860
|
+
this.a = a;
|
|
50861
|
+
}
|
|
50862
|
+
static fromThree(color, opacity = 1) {
|
|
50863
|
+
return new RGBA(color.r, color.g, color.b, opacity);
|
|
50864
|
+
}
|
|
50865
|
+
toThree() {
|
|
50866
|
+
return new Color(this.r, this.g, this.b);
|
|
50867
|
+
}
|
|
50868
|
+
clone() {
|
|
50869
|
+
return new RGBA(this.r, this.g, this.b, this.a);
|
|
50870
|
+
}
|
|
50871
|
+
isValid() {
|
|
50872
|
+
return Number.isFinite(this.r) && Number.isFinite(this.g) && Number.isFinite(this.b) && Number.isFinite(this.a);
|
|
50873
|
+
}
|
|
50874
|
+
equals(color) {
|
|
50875
|
+
return this.r === color.r && this.g === color.g && this.b === color.b && this.a === color.a;
|
|
50876
|
+
}
|
|
50877
|
+
static fromString(str) {
|
|
50878
|
+
str = str.trim();
|
|
50879
|
+
if (str.startsWith("(")) {
|
|
50880
|
+
str = str.substring(1);
|
|
50881
|
+
}
|
|
50882
|
+
if (str.endsWith(")")) {
|
|
50883
|
+
str = str.substring(0, str.length - 1);
|
|
50884
|
+
}
|
|
50885
|
+
const parts = str.split(",");
|
|
50886
|
+
if (parts.length < 3 || parts.length > 4) {
|
|
50887
|
+
throw new Error("Invalid color string format. Expected 3 or 4 components.");
|
|
50888
|
+
}
|
|
50889
|
+
const r = parseFloat(parts[0]);
|
|
50890
|
+
const g = parseFloat(parts[1]);
|
|
50891
|
+
const b = parseFloat(parts[2]);
|
|
50892
|
+
const a = parts.length === 4 ? parseFloat(parts[3]) : 1;
|
|
50893
|
+
if ([r, g, b, a].some((n) => isNaN(n))) {
|
|
50894
|
+
throw new Error("Invalid number in color string.");
|
|
50895
|
+
}
|
|
50896
|
+
return new RGBA(r, g, b, a);
|
|
50897
|
+
}
|
|
50898
|
+
}
|
|
50899
|
+
class RGB {
|
|
50900
|
+
constructor(r, g, b) {
|
|
50901
|
+
__publicField(this, "r");
|
|
50902
|
+
__publicField(this, "g");
|
|
50903
|
+
__publicField(this, "b");
|
|
50904
|
+
this.r = r;
|
|
50905
|
+
this.g = g;
|
|
50906
|
+
this.b = b;
|
|
50907
|
+
}
|
|
50908
|
+
}
|
|
50909
|
+
class RGBA32 {
|
|
50910
|
+
constructor(hex) {
|
|
50911
|
+
__publicField(this, "hex");
|
|
50912
|
+
if (!Number.isInteger(hex) || hex < 0 || hex > 4294967295) {
|
|
50913
|
+
throw new Error("Invalid value: must be a 32-bit unsigned integer");
|
|
50914
|
+
}
|
|
50915
|
+
this.hex = hex;
|
|
50916
|
+
}
|
|
50917
|
+
static fromThree(color, opacity = 1) {
|
|
50918
|
+
return this.fromFloats(color.r, color.g, color.b, opacity);
|
|
50919
|
+
}
|
|
50920
|
+
static fromInts(r, g, b, a = 1) {
|
|
50921
|
+
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255 || a < 0 || a > 255) {
|
|
50922
|
+
throw new Error("Each RGBA component must be in the range 0-255.");
|
|
50923
|
+
}
|
|
50924
|
+
const hex = r * 2 ** 24 + g * 2 ** 16 + b * 2 ** 8 + a;
|
|
50925
|
+
return new RGBA32(hex);
|
|
50926
|
+
}
|
|
50927
|
+
static fromFloats(r, g, b, a = 1) {
|
|
50928
|
+
return this.fromInts(
|
|
50929
|
+
remap(r, 255),
|
|
50930
|
+
remap(g, 255),
|
|
50931
|
+
remap(b, 255),
|
|
50932
|
+
remap(a, 255)
|
|
50933
|
+
);
|
|
50934
|
+
}
|
|
50935
|
+
static fromString(str) {
|
|
50936
|
+
if (str.startsWith("#")) {
|
|
50937
|
+
str = str.slice(1);
|
|
50938
|
+
}
|
|
50939
|
+
if (str.length === 3 || str.length === 4) {
|
|
50940
|
+
str = str.split("").map((c) => c + c).join("");
|
|
50941
|
+
}
|
|
50942
|
+
let r = 0;
|
|
50943
|
+
let g = 0;
|
|
50944
|
+
let b = 0;
|
|
50945
|
+
let a = 255;
|
|
50946
|
+
if (str.length === 6 || str.length === 8) {
|
|
50947
|
+
r = parseInt(str.slice(0, 2), 16);
|
|
50948
|
+
g = parseInt(str.slice(2, 4), 16);
|
|
50949
|
+
b = parseInt(str.slice(4, 6), 16);
|
|
50950
|
+
if (str.length === 8) {
|
|
50951
|
+
a = parseInt(str.slice(6, 8), 16);
|
|
50952
|
+
}
|
|
50953
|
+
} else {
|
|
50954
|
+
throw new Error("Invalid color string format");
|
|
50955
|
+
}
|
|
50956
|
+
if ([r, g, b, a].some((v) => isNaN(v))) {
|
|
50957
|
+
throw new Error("Invalid color string format");
|
|
50958
|
+
}
|
|
50959
|
+
return this.fromInts(r, g, b, a);
|
|
50960
|
+
}
|
|
50961
|
+
/**
|
|
50962
|
+
* The red component of the color in the range [0-255].
|
|
50963
|
+
*/
|
|
50964
|
+
get r() {
|
|
50965
|
+
return this.hex >>> 24;
|
|
50966
|
+
}
|
|
50967
|
+
/**
|
|
50968
|
+
* The green component of the color in the range [0-255].
|
|
50969
|
+
*/
|
|
50970
|
+
get g() {
|
|
50971
|
+
return this.hex >>> 16 & 255;
|
|
50972
|
+
}
|
|
50973
|
+
/**
|
|
50974
|
+
* The blue component of the color in the range [0-255].
|
|
50975
|
+
*/
|
|
50976
|
+
get b() {
|
|
50977
|
+
return this.hex >>> 8 & 255;
|
|
50978
|
+
}
|
|
50979
|
+
/**
|
|
50980
|
+
* The alpha component of the color in the range [0-255].
|
|
50981
|
+
*/
|
|
50982
|
+
get a() {
|
|
50983
|
+
return this.hex & 255;
|
|
50984
|
+
}
|
|
50985
|
+
}
|
|
50828
50986
|
class Validation {
|
|
50829
50987
|
//= ===========================================================================
|
|
50830
50988
|
// BASIC NUMBER VALIDATIONS
|
|
@@ -50934,23 +51092,6 @@ class Validation {
|
|
|
50934
51092
|
return true;
|
|
50935
51093
|
}
|
|
50936
51094
|
//= ===========================================================================
|
|
50937
|
-
// COLOR VALIDATIONS
|
|
50938
|
-
//= ===========================================================================
|
|
50939
|
-
static isRelativeRGBA(color) {
|
|
50940
|
-
if (color.r < 0 || color.r > 1 || color.g < 0 || color.g > 1 || color.b < 0 || color.b > 1) {
|
|
50941
|
-
console.warn("Invalid value: must be a relative color (0-1, 0-1, 0-1)");
|
|
50942
|
-
return false;
|
|
50943
|
-
}
|
|
50944
|
-
return true;
|
|
50945
|
-
}
|
|
50946
|
-
static isRelativeRGB(color) {
|
|
50947
|
-
if (color.r < 0 || color.r > 1 || color.g < 0 || color.g > 1 || color.b < 0 || color.b > 1) {
|
|
50948
|
-
console.warn("Invalid value: must be a relative color (0-1, 0-1, 0-1)");
|
|
50949
|
-
return false;
|
|
50950
|
-
}
|
|
50951
|
-
return true;
|
|
50952
|
-
}
|
|
50953
|
-
//= ===========================================================================
|
|
50954
51095
|
// STRING AND URL VALIDATIONS
|
|
50955
51096
|
//= ===========================================================================
|
|
50956
51097
|
static isNonEmptyString(value) {
|
|
@@ -51037,6 +51178,13 @@ class Validation {
|
|
|
51037
51178
|
}
|
|
51038
51179
|
return value;
|
|
51039
51180
|
}
|
|
51181
|
+
static clampColor01(value) {
|
|
51182
|
+
return new Color(
|
|
51183
|
+
this.clamp01(value.r),
|
|
51184
|
+
this.clamp01(value.g),
|
|
51185
|
+
this.clamp01(value.b)
|
|
51186
|
+
);
|
|
51187
|
+
}
|
|
51040
51188
|
static clampRGBA01(value) {
|
|
51041
51189
|
return new RGBA(
|
|
51042
51190
|
this.clamp01(value.r),
|
|
@@ -57317,155 +57465,6 @@ const index$8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
57317
57465
|
getDefaultVimSettings,
|
|
57318
57466
|
request: requestVim
|
|
57319
57467
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
57320
|
-
class Segment {
|
|
57321
|
-
constructor(origin = new Vector3(), target = new Vector3()) {
|
|
57322
|
-
__publicField(this, "origin");
|
|
57323
|
-
__publicField(this, "target");
|
|
57324
|
-
this.origin = origin;
|
|
57325
|
-
this.target = target;
|
|
57326
|
-
}
|
|
57327
|
-
static fromArray(array) {
|
|
57328
|
-
return new Segment(
|
|
57329
|
-
new Vector3(array[0], array[1], array[2]),
|
|
57330
|
-
new Vector3(array[3], array[4], array[5])
|
|
57331
|
-
);
|
|
57332
|
-
}
|
|
57333
|
-
toArray() {
|
|
57334
|
-
return [this.origin.x, this.origin.y, this.origin.z, this.target.x, this.target.y, this.target.z];
|
|
57335
|
-
}
|
|
57336
|
-
isValid() {
|
|
57337
|
-
return !this.origin.equals(this.target);
|
|
57338
|
-
}
|
|
57339
|
-
equals(segment) {
|
|
57340
|
-
return this.origin.equals(segment.origin) && this.target.equals(segment.target);
|
|
57341
|
-
}
|
|
57342
|
-
}
|
|
57343
|
-
class RGBA {
|
|
57344
|
-
constructor(r, g, b, a = 1) {
|
|
57345
|
-
__publicField(this, "r");
|
|
57346
|
-
__publicField(this, "g");
|
|
57347
|
-
__publicField(this, "b");
|
|
57348
|
-
__publicField(this, "a");
|
|
57349
|
-
this.r = r;
|
|
57350
|
-
this.g = g;
|
|
57351
|
-
this.b = b;
|
|
57352
|
-
this.a = a;
|
|
57353
|
-
}
|
|
57354
|
-
clone() {
|
|
57355
|
-
return new RGBA(this.r, this.g, this.b, this.a);
|
|
57356
|
-
}
|
|
57357
|
-
isValid() {
|
|
57358
|
-
return Number.isFinite(this.r) && Number.isFinite(this.g) && Number.isFinite(this.b) && Number.isFinite(this.a);
|
|
57359
|
-
}
|
|
57360
|
-
equals(color) {
|
|
57361
|
-
return this.r === color.r && this.g === color.g && this.b === color.b && this.a === color.a;
|
|
57362
|
-
}
|
|
57363
|
-
static fromString(str) {
|
|
57364
|
-
str = str.trim();
|
|
57365
|
-
if (str.startsWith("(")) {
|
|
57366
|
-
str = str.substring(1);
|
|
57367
|
-
}
|
|
57368
|
-
if (str.endsWith(")")) {
|
|
57369
|
-
str = str.substring(0, str.length - 1);
|
|
57370
|
-
}
|
|
57371
|
-
const parts = str.split(",");
|
|
57372
|
-
if (parts.length < 3 || parts.length > 4) {
|
|
57373
|
-
throw new Error("Invalid color string format. Expected 3 or 4 components.");
|
|
57374
|
-
}
|
|
57375
|
-
const r = parseFloat(parts[0]);
|
|
57376
|
-
const g = parseFloat(parts[1]);
|
|
57377
|
-
const b = parseFloat(parts[2]);
|
|
57378
|
-
const a = parts.length === 4 ? parseFloat(parts[3]) : 1;
|
|
57379
|
-
if ([r, g, b, a].some((n) => isNaN(n))) {
|
|
57380
|
-
throw new Error("Invalid number in color string.");
|
|
57381
|
-
}
|
|
57382
|
-
return new RGBA(r, g, b, a);
|
|
57383
|
-
}
|
|
57384
|
-
}
|
|
57385
|
-
class RGB {
|
|
57386
|
-
constructor(r, g, b) {
|
|
57387
|
-
__publicField(this, "r");
|
|
57388
|
-
__publicField(this, "g");
|
|
57389
|
-
__publicField(this, "b");
|
|
57390
|
-
this.r = r;
|
|
57391
|
-
this.g = g;
|
|
57392
|
-
this.b = b;
|
|
57393
|
-
}
|
|
57394
|
-
}
|
|
57395
|
-
class RGBA32 {
|
|
57396
|
-
constructor(hex) {
|
|
57397
|
-
__publicField(this, "hex");
|
|
57398
|
-
if (!Number.isInteger(hex) || hex < 0 || hex > 4294967295) {
|
|
57399
|
-
throw new Error("Invalid value: must be a 32-bit unsigned integer");
|
|
57400
|
-
}
|
|
57401
|
-
this.hex = hex;
|
|
57402
|
-
}
|
|
57403
|
-
static fromInts(r, g, b, a = 1) {
|
|
57404
|
-
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255 || a < 0 || a > 255) {
|
|
57405
|
-
throw new Error("Each RGBA component must be in the range 0-255.");
|
|
57406
|
-
}
|
|
57407
|
-
const hex = r * 2 ** 24 + g * 2 ** 16 + b * 2 ** 8 + a;
|
|
57408
|
-
return new RGBA32(hex);
|
|
57409
|
-
}
|
|
57410
|
-
static fromFloats(r, g, b, a = 1) {
|
|
57411
|
-
return this.fromInts(
|
|
57412
|
-
remap(r, 255),
|
|
57413
|
-
remap(g, 255),
|
|
57414
|
-
remap(b, 255),
|
|
57415
|
-
remap(a, 255)
|
|
57416
|
-
);
|
|
57417
|
-
}
|
|
57418
|
-
static fromString(str) {
|
|
57419
|
-
if (str.startsWith("#")) {
|
|
57420
|
-
str = str.slice(1);
|
|
57421
|
-
}
|
|
57422
|
-
if (str.length === 3 || str.length === 4) {
|
|
57423
|
-
str = str.split("").map((c) => c + c).join("");
|
|
57424
|
-
}
|
|
57425
|
-
let r = 0;
|
|
57426
|
-
let g = 0;
|
|
57427
|
-
let b = 0;
|
|
57428
|
-
let a = 255;
|
|
57429
|
-
if (str.length === 6 || str.length === 8) {
|
|
57430
|
-
r = parseInt(str.slice(0, 2), 16);
|
|
57431
|
-
g = parseInt(str.slice(2, 4), 16);
|
|
57432
|
-
b = parseInt(str.slice(4, 6), 16);
|
|
57433
|
-
if (str.length === 8) {
|
|
57434
|
-
a = parseInt(str.slice(6, 8), 16);
|
|
57435
|
-
}
|
|
57436
|
-
} else {
|
|
57437
|
-
throw new Error("Invalid color string format");
|
|
57438
|
-
}
|
|
57439
|
-
if ([r, g, b, a].some((v) => isNaN(v))) {
|
|
57440
|
-
throw new Error("Invalid color string format");
|
|
57441
|
-
}
|
|
57442
|
-
return this.fromInts(r, g, b, a);
|
|
57443
|
-
}
|
|
57444
|
-
/**
|
|
57445
|
-
* The red component of the color in the range [0-255].
|
|
57446
|
-
*/
|
|
57447
|
-
get r() {
|
|
57448
|
-
return this.hex >>> 24;
|
|
57449
|
-
}
|
|
57450
|
-
/**
|
|
57451
|
-
* The green component of the color in the range [0-255].
|
|
57452
|
-
*/
|
|
57453
|
-
get g() {
|
|
57454
|
-
return this.hex >>> 16 & 255;
|
|
57455
|
-
}
|
|
57456
|
-
/**
|
|
57457
|
-
* The blue component of the color in the range [0-255].
|
|
57458
|
-
*/
|
|
57459
|
-
get b() {
|
|
57460
|
-
return this.hex >>> 8 & 255;
|
|
57461
|
-
}
|
|
57462
|
-
/**
|
|
57463
|
-
* The alpha component of the color in the range [0-255].
|
|
57464
|
-
*/
|
|
57465
|
-
get a() {
|
|
57466
|
-
return this.hex & 255;
|
|
57467
|
-
}
|
|
57468
|
-
}
|
|
57469
57468
|
class Camera3 {
|
|
57470
57469
|
/**
|
|
57471
57470
|
* Creates a new Camera instance
|
|
@@ -58324,35 +58323,7 @@ class RemoteColor {
|
|
|
58324
58323
|
* @returns {number} The color value as a hexadecimal number.
|
|
58325
58324
|
*/
|
|
58326
58325
|
get hex() {
|
|
58327
|
-
return this.color.
|
|
58328
|
-
}
|
|
58329
|
-
/**
|
|
58330
|
-
* Gets the red component of the color.
|
|
58331
|
-
* @returns {number} The red component value in the range [0-255].
|
|
58332
|
-
*/
|
|
58333
|
-
get r() {
|
|
58334
|
-
return this.color.r;
|
|
58335
|
-
}
|
|
58336
|
-
/**
|
|
58337
|
-
* Gets the green component of the color.
|
|
58338
|
-
* @returns {number} The green component value in the range [0-255].
|
|
58339
|
-
*/
|
|
58340
|
-
get g() {
|
|
58341
|
-
return this.color.g;
|
|
58342
|
-
}
|
|
58343
|
-
/**
|
|
58344
|
-
* Gets the blue component of the color.
|
|
58345
|
-
* @returns {number} The blue component value in the range [0-255].
|
|
58346
|
-
*/
|
|
58347
|
-
get b() {
|
|
58348
|
-
return this.color.b;
|
|
58349
|
-
}
|
|
58350
|
-
/**
|
|
58351
|
-
* Gets the alpha (opacity) component of the color.
|
|
58352
|
-
* @returns {number} The alpha component value in the range [0-255].
|
|
58353
|
-
*/
|
|
58354
|
-
get a() {
|
|
58355
|
-
return this.color.a;
|
|
58326
|
+
return this.color.getHex();
|
|
58356
58327
|
}
|
|
58357
58328
|
/**
|
|
58358
58329
|
* Disposes of the color handle and releases associated resources.
|
|
@@ -58365,6 +58336,12 @@ class RemoteColor {
|
|
|
58365
58336
|
this._disposed = true;
|
|
58366
58337
|
}
|
|
58367
58338
|
}
|
|
58339
|
+
function RGBAfromThree(color, opacity = 1) {
|
|
58340
|
+
return new RGBA(color.r, color.g, color.b, opacity);
|
|
58341
|
+
}
|
|
58342
|
+
function RGBA32fromThree(color, opacity = 1) {
|
|
58343
|
+
return RGBA32.fromFloats(color.r, color.g, color.b, opacity);
|
|
58344
|
+
}
|
|
58368
58345
|
const MAX_BATCH_SIZE = 3e3;
|
|
58369
58346
|
class ColorManager {
|
|
58370
58347
|
/**
|
|
@@ -58384,39 +58361,40 @@ class ColorManager {
|
|
|
58384
58361
|
* @param hex - The RGBA32 color value
|
|
58385
58362
|
* @returns Promise resolving to a ColorHandle, or undefined if creation fails
|
|
58386
58363
|
*/
|
|
58387
|
-
async getColor(
|
|
58388
|
-
const colors = await this.getColors([
|
|
58364
|
+
async getColor(color) {
|
|
58365
|
+
const colors = await this.getColors([color]);
|
|
58389
58366
|
if (!colors) return void 0;
|
|
58390
58367
|
return colors[0];
|
|
58391
58368
|
}
|
|
58392
58369
|
/**
|
|
58393
58370
|
* Creates or retrieves cached color instances for multiple hex values.
|
|
58394
|
-
* @param
|
|
58371
|
+
* @param colors - Array of RGBA32 color values
|
|
58395
58372
|
* @returns Promise resolving to an array of ColorHandles in the same order as input, or undefined if creation fails
|
|
58396
58373
|
* @remarks Duplicate hex values will be mapped to the same color instance for efficiency
|
|
58397
58374
|
*/
|
|
58398
|
-
async getColors(
|
|
58399
|
-
const result = new Array(
|
|
58375
|
+
async getColors(colors) {
|
|
58376
|
+
const result = new Array(colors.length);
|
|
58400
58377
|
const hexToIndices = /* @__PURE__ */ new Map();
|
|
58401
58378
|
const toCreate = [];
|
|
58402
|
-
for (let i = 0; i <
|
|
58403
|
-
const color =
|
|
58404
|
-
|
|
58405
|
-
|
|
58406
|
-
|
|
58407
|
-
|
|
58379
|
+
for (let i = 0; i < colors.length; i++) {
|
|
58380
|
+
const color = colors[i];
|
|
58381
|
+
const hex = color.getHex();
|
|
58382
|
+
if (this._hexToColor.has(hex)) {
|
|
58383
|
+
result[i] = this._hexToColor.get(hex);
|
|
58384
|
+
} else if (hexToIndices.has(hex)) {
|
|
58385
|
+
hexToIndices.get(hex).push(i);
|
|
58408
58386
|
} else {
|
|
58409
58387
|
toCreate.push(color);
|
|
58410
|
-
hexToIndices.set(
|
|
58388
|
+
hexToIndices.set(hex, [i]);
|
|
58411
58389
|
}
|
|
58412
58390
|
}
|
|
58413
|
-
const
|
|
58414
|
-
if (!
|
|
58415
|
-
for (let i = 0; i <
|
|
58391
|
+
const remoteColors = await this._createColors(toCreate);
|
|
58392
|
+
if (!remoteColors) return void 0;
|
|
58393
|
+
for (let i = 0; i < remoteColors.length; i++) {
|
|
58416
58394
|
const color = toCreate[i];
|
|
58417
|
-
const indices = hexToIndices.get(color.
|
|
58395
|
+
const indices = hexToIndices.get(color.getHex());
|
|
58418
58396
|
for (const index2 of indices) {
|
|
58419
|
-
result[index2] =
|
|
58397
|
+
result[index2] = remoteColors[i];
|
|
58420
58398
|
}
|
|
58421
58399
|
}
|
|
58422
58400
|
return result;
|
|
@@ -58459,7 +58437,8 @@ class ColorManager {
|
|
|
58459
58437
|
if (colors.length === 0) {
|
|
58460
58438
|
return result;
|
|
58461
58439
|
}
|
|
58462
|
-
const
|
|
58440
|
+
const rpcColors = colors.map((c) => RGBA32fromThree(c));
|
|
58441
|
+
const instances = await this._rpc.RPCCreateMaterialInstances(MaterialHandles.StandardOpaque, 1, rpcColors);
|
|
58463
58442
|
if (!instances) return void 0;
|
|
58464
58443
|
for (let i = 0; i < colors.length; i++) {
|
|
58465
58444
|
const color = this._createColor(colors[i], instances[i]);
|
|
@@ -58476,7 +58455,7 @@ class ColorManager {
|
|
|
58476
58455
|
*/
|
|
58477
58456
|
_createColor(color, id2) {
|
|
58478
58457
|
const handle = new RemoteColor(color, id2, this);
|
|
58479
|
-
this._hexToColor.set(color.
|
|
58458
|
+
this._hexToColor.set(color.getHex(), handle);
|
|
58480
58459
|
this._idToColor.set(handle.id, handle);
|
|
58481
58460
|
return handle;
|
|
58482
58461
|
}
|
|
@@ -59743,7 +59722,8 @@ class RpcSafeClient {
|
|
|
59743
59722
|
}
|
|
59744
59723
|
const defaultRenderSettings = {
|
|
59745
59724
|
...defaultSceneSettings,
|
|
59746
|
-
ghostColor: new
|
|
59725
|
+
ghostColor: new Color(14 / 255, 14 / 255, 14 / 255),
|
|
59726
|
+
ghostOpacity: 64 / 255
|
|
59747
59727
|
};
|
|
59748
59728
|
class Renderer2 {
|
|
59749
59729
|
/**
|
|
@@ -59790,7 +59770,8 @@ class Renderer2 {
|
|
|
59790
59770
|
* Sets up initial scene settings, ghost color, and IBL rotation
|
|
59791
59771
|
*/
|
|
59792
59772
|
onConnect() {
|
|
59793
|
-
this.
|
|
59773
|
+
const color = RGBAfromThree(this._settings.ghostColor, this._settings.ghostOpacity);
|
|
59774
|
+
this._rpc.RPCSetGhostColor(color);
|
|
59794
59775
|
}
|
|
59795
59776
|
notifySceneUpdated() {
|
|
59796
59777
|
this._onSceneUpdated.dispatch();
|
|
@@ -59798,11 +59779,14 @@ class Renderer2 {
|
|
|
59798
59779
|
// Getters
|
|
59799
59780
|
/**
|
|
59800
59781
|
* Gets the ghost color used for transparent rendering
|
|
59801
|
-
* @returns Current ghost color as
|
|
59782
|
+
* @returns Current ghost color as a THREE.Color
|
|
59802
59783
|
*/
|
|
59803
59784
|
get ghostColor() {
|
|
59804
59785
|
return this._settings.ghostColor;
|
|
59805
59786
|
}
|
|
59787
|
+
get ghostOpacity() {
|
|
59788
|
+
return this._settings.ghostOpacity;
|
|
59789
|
+
}
|
|
59806
59790
|
/**
|
|
59807
59791
|
* Gets the tone mapping white point value
|
|
59808
59792
|
* @returns Current tone mapping white point
|
|
@@ -59843,20 +59827,26 @@ class Renderer2 {
|
|
|
59843
59827
|
* @returns Current background color as RGBA
|
|
59844
59828
|
*/
|
|
59845
59829
|
get backgroundColor() {
|
|
59846
|
-
return this._settings.backgroundColor;
|
|
59830
|
+
return this._settings.backgroundColor.toThree();
|
|
59847
59831
|
}
|
|
59848
59832
|
// Setters
|
|
59849
59833
|
/**
|
|
59850
59834
|
* Updates the ghost color used for transparent rendering
|
|
59851
|
-
* @param value - New ghost color as
|
|
59835
|
+
* @param value - New ghost color as THREE.Color
|
|
59852
59836
|
*/
|
|
59853
59837
|
set ghostColor(value) {
|
|
59854
|
-
value = Validation.clampRGBA01(value);
|
|
59855
59838
|
if (this._settings.ghostColor.equals(value)) return;
|
|
59856
59839
|
this._settings.ghostColor = value;
|
|
59857
59840
|
this._updateGhostColor = true;
|
|
59858
59841
|
this.requestSettingsUpdate();
|
|
59859
59842
|
}
|
|
59843
|
+
set ghostOpacity(value) {
|
|
59844
|
+
value = Validation.clamp01(value);
|
|
59845
|
+
if (this._settings.ghostOpacity === value) return;
|
|
59846
|
+
this._settings.ghostOpacity = value;
|
|
59847
|
+
this._updateGhostColor = true;
|
|
59848
|
+
this.requestSettingsUpdate();
|
|
59849
|
+
}
|
|
59860
59850
|
/**
|
|
59861
59851
|
* Sets the tone mapping white point value
|
|
59862
59852
|
* @param value - New tone mapping white point value
|
|
@@ -59914,12 +59904,12 @@ class Renderer2 {
|
|
|
59914
59904
|
}
|
|
59915
59905
|
/**
|
|
59916
59906
|
* Sets the background color
|
|
59917
|
-
* @param value - New background color as
|
|
59907
|
+
* @param value - New background color as THREE.Color
|
|
59918
59908
|
*/
|
|
59919
59909
|
set backgroundColor(value) {
|
|
59920
|
-
|
|
59921
|
-
if (this._settings.backgroundColor.equals(
|
|
59922
|
-
this._settings.backgroundColor =
|
|
59910
|
+
const color = RGBAfromThree(value, 1);
|
|
59911
|
+
if (this._settings.backgroundColor.equals(color)) return;
|
|
59912
|
+
this._settings.backgroundColor = color;
|
|
59923
59913
|
this._updateLighting = true;
|
|
59924
59914
|
this.requestSettingsUpdate();
|
|
59925
59915
|
}
|
|
@@ -59939,7 +59929,10 @@ class Renderer2 {
|
|
|
59939
59929
|
}
|
|
59940
59930
|
async applySettings() {
|
|
59941
59931
|
if (this._updateLighting) await this._rpc.RPCSetLighting(this._settings);
|
|
59942
|
-
if (this._updateGhostColor)
|
|
59932
|
+
if (this._updateGhostColor) {
|
|
59933
|
+
const color = RGBAfromThree(this._settings.ghostColor, this._settings.ghostOpacity);
|
|
59934
|
+
await this._rpc.RPCSetGhostColor(color);
|
|
59935
|
+
}
|
|
59943
59936
|
this._updateLighting = false;
|
|
59944
59937
|
this._updateGhostColor = false;
|
|
59945
59938
|
this._animationFrame = void 0;
|
|
@@ -60864,7 +60857,7 @@ class Vim2 {
|
|
|
60864
60857
|
// Should be private
|
|
60865
60858
|
__publicField(this, "visibility");
|
|
60866
60859
|
// Color tracking remains unchanged.
|
|
60867
|
-
__publicField(this, "
|
|
60860
|
+
__publicField(this, "_elementColors", /* @__PURE__ */ new Map());
|
|
60868
60861
|
__publicField(this, "_updatedColors", /* @__PURE__ */ new Set());
|
|
60869
60862
|
// Delayed update flag.
|
|
60870
60863
|
__publicField(this, "_updateScheduled", false);
|
|
@@ -60884,6 +60877,7 @@ class Vim2 {
|
|
|
60884
60877
|
// default state
|
|
60885
60878
|
);
|
|
60886
60879
|
}
|
|
60880
|
+
//TODO: Rename this to getElementFromNode, prefer using element instead
|
|
60887
60881
|
getElement(elementIndex) {
|
|
60888
60882
|
if (this._objects.has(elementIndex)) {
|
|
60889
60883
|
return this._objects.get(elementIndex);
|
|
@@ -60896,7 +60890,7 @@ class Vim2 {
|
|
|
60896
60890
|
throw new Error("Method not implemented.");
|
|
60897
60891
|
}
|
|
60898
60892
|
getElementFromIndex(element) {
|
|
60899
|
-
|
|
60893
|
+
return this.getElement(element);
|
|
60900
60894
|
}
|
|
60901
60895
|
getObjectsInBox(box) {
|
|
60902
60896
|
throw new Error("Method not implemented.");
|
|
@@ -61017,12 +61011,12 @@ class Vim2 {
|
|
|
61017
61011
|
}
|
|
61018
61012
|
return await this._rpc.RPCGetAABBForVim(this._handle);
|
|
61019
61013
|
}
|
|
61020
|
-
getColor(
|
|
61021
|
-
return this.
|
|
61014
|
+
getColor(elementIndex) {
|
|
61015
|
+
return this._elementColors.get(elementIndex);
|
|
61022
61016
|
}
|
|
61023
|
-
async setColor(
|
|
61024
|
-
const colors = new Array(
|
|
61025
|
-
this.applyColor(
|
|
61017
|
+
async setColor(elementIndex, color) {
|
|
61018
|
+
const colors = new Array(elementIndex.length).fill(color);
|
|
61019
|
+
this.applyColor(elementIndex, colors);
|
|
61026
61020
|
}
|
|
61027
61021
|
async setColors(nodes, color) {
|
|
61028
61022
|
if (color.length !== nodes.length) {
|
|
@@ -61035,9 +61029,9 @@ class Vim2 {
|
|
|
61035
61029
|
const c = color[i];
|
|
61036
61030
|
const n = nodes[i];
|
|
61037
61031
|
if (c === void 0) {
|
|
61038
|
-
this.
|
|
61032
|
+
this._elementColors.delete(n);
|
|
61039
61033
|
} else {
|
|
61040
|
-
this.
|
|
61034
|
+
this._elementColors.set(n, c);
|
|
61041
61035
|
}
|
|
61042
61036
|
this._updatedColors.add(n);
|
|
61043
61037
|
}
|
|
@@ -61045,9 +61039,9 @@ class Vim2 {
|
|
|
61045
61039
|
}
|
|
61046
61040
|
clearColor(elements) {
|
|
61047
61041
|
if (elements === "all") {
|
|
61048
|
-
this.
|
|
61042
|
+
this._elementColors.clear();
|
|
61049
61043
|
} else {
|
|
61050
|
-
elements.forEach((n) => this.
|
|
61044
|
+
elements.forEach((n) => this._elementColors.delete(n));
|
|
61051
61045
|
}
|
|
61052
61046
|
if (!this.connected) return;
|
|
61053
61047
|
if (elements === "all") {
|
|
@@ -61059,7 +61053,7 @@ class Vim2 {
|
|
|
61059
61053
|
}
|
|
61060
61054
|
reapplyColors() {
|
|
61061
61055
|
this._updatedColors.clear();
|
|
61062
|
-
this.
|
|
61056
|
+
this._elementColors.forEach((c, n) => this._updatedColors.add(n));
|
|
61063
61057
|
this.scheduleColorUpdate();
|
|
61064
61058
|
}
|
|
61065
61059
|
scheduleColorUpdate() {
|
|
@@ -61076,7 +61070,7 @@ class Vim2 {
|
|
|
61076
61070
|
}
|
|
61077
61071
|
async updateRemoteColors() {
|
|
61078
61072
|
const nodes = Array.from(this._updatedColors);
|
|
61079
|
-
const colors = nodes.map((n) => this.
|
|
61073
|
+
const colors = nodes.map((n) => this._elementColors.get(n));
|
|
61080
61074
|
const remoteColors = await this._colors.getColors(colors);
|
|
61081
61075
|
const colorIds = remoteColors.map((c) => (c == null ? void 0 : c.id) ?? -1);
|
|
61082
61076
|
this._rpc.RPCSetMaterialOverridesForElements(this._handle, nodes, colorIds);
|
|
@@ -61404,9 +61398,6 @@ const index$7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
61404
61398
|
INVALID_HANDLE,
|
|
61405
61399
|
InputMode,
|
|
61406
61400
|
MaterialHandles,
|
|
61407
|
-
RGB,
|
|
61408
|
-
RGBA,
|
|
61409
|
-
RGBA32,
|
|
61410
61401
|
Segment,
|
|
61411
61402
|
Viewer: Viewer$2,
|
|
61412
61403
|
VimLoadingStatus,
|
|
@@ -76278,6 +76269,7 @@ function createAdapter(viewer) {
|
|
|
76278
76269
|
obj.state = VisibilityState.HIGHLIGHTED;
|
|
76279
76270
|
});
|
|
76280
76271
|
},
|
|
76272
|
+
// TODO: Change this api to use elements
|
|
76281
76273
|
isolate: (instances) => {
|
|
76282
76274
|
hide("all");
|
|
76283
76275
|
viewer.selection.getAll().forEach((obj) => {
|
|
@@ -76311,11 +76303,9 @@ function createAdapter(viewer) {
|
|
|
76311
76303
|
}
|
|
76312
76304
|
}
|
|
76313
76305
|
},
|
|
76314
|
-
getGhostOpacity: () => viewer.renderer.
|
|
76306
|
+
getGhostOpacity: () => viewer.renderer.ghostOpacity,
|
|
76315
76307
|
setGhostOpacity: (opacity) => {
|
|
76316
|
-
|
|
76317
|
-
c.a = opacity;
|
|
76318
|
-
viewer.renderer.ghostColor = c;
|
|
76308
|
+
viewer.renderer.ghostOpacity = opacity;
|
|
76319
76309
|
},
|
|
76320
76310
|
getShowRooms: () => true,
|
|
76321
76311
|
setShowRooms: (show) => {
|