@rocketshow/designer 1.35.0 → 1.36.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.
@@ -1029,9 +1029,21 @@ class FixtureService {
1029
1029
  }
1030
1030
  }
1031
1031
  }
1032
+ fixtureUuidAndPixelKeyEquals(fixtureUuid1, fixtureUuid2, pixelKey1, pixelKey2) {
1033
+ return fixtureUuid1 === fixtureUuid2 && ((pixelKey1 == null && pixelKey2 == null) || pixelKey1 === pixelKey2);
1034
+ }
1032
1035
  getCachedFixtureByUuid(uuid, pixelKey) {
1033
1036
  for (const fixture of this.cachedFixtures) {
1034
- if (fixture.fixture.uuid === uuid && ((!fixture.pixelKey && !pixelKey) || fixture.pixelKey === pixelKey)) {
1037
+ if (this.fixtureUuidAndPixelKeyEquals(fixture.fixture.uuid, uuid, fixture.pixelKey, pixelKey)) {
1038
+ return fixture;
1039
+ }
1040
+ }
1041
+ // not yet found -> try searching the fixture without pixelKey for the general channels
1042
+ if (pixelKey) {
1043
+ return undefined;
1044
+ }
1045
+ for (const fixture of this.cachedFixtures) {
1046
+ if (!fixture.pixelKey && fixture.fixture.uuid === uuid) {
1035
1047
  return fixture;
1036
1048
  }
1037
1049
  }
@@ -1250,9 +1262,12 @@ class FixtureService {
1250
1262
  }
1251
1263
  return undefined;
1252
1264
  }
1265
+ getChannelNameWithPixelKey(templateChannelName, pixelKey) {
1266
+ return templateChannelName.replace('$pixelKey', pixelKey);
1267
+ }
1253
1268
  addCachedChannel(channels, channel, templateChannelName, pixelKey, profile) {
1254
1269
  const cachedFixtureChannel = new CachedFixtureChannel();
1255
- const channelName = templateChannelName.replace('$pixelKey', pixelKey);
1270
+ const channelName = this.getChannelNameWithPixelKey(templateChannelName, pixelKey);
1256
1271
  cachedFixtureChannel.channel = channel;
1257
1272
  cachedFixtureChannel.name = channelName;
1258
1273
  cachedFixtureChannel.capabilities = this.getCapabilitiesByChannel(cachedFixtureChannel.channel, channelName, profile);
@@ -1267,6 +1282,26 @@ class FixtureService {
1267
1282
  alphanumericSort(a, b) {
1268
1283
  return a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' });
1269
1284
  }
1285
+ getAllPixelKeys(profile) {
1286
+ let result = [];
1287
+ for (let pixelKeyX of profile.matrix.pixelKeys) {
1288
+ for (let pixelKeyY of pixelKeyX) {
1289
+ for (let pixelKeyZ of pixelKeyY) {
1290
+ if (pixelKeyZ) {
1291
+ result.push(pixelKeyZ);
1292
+ }
1293
+ }
1294
+ }
1295
+ }
1296
+ return result;
1297
+ }
1298
+ getAllPixelGroups(profile) {
1299
+ let result = [];
1300
+ for (const property of Object.keys(profile.matrix.pixelGroups)) {
1301
+ result.push(property);
1302
+ }
1303
+ return result;
1304
+ }
1270
1305
  getPixelKeysInOrder(profile, repeatFor) {
1271
1306
  let result = [];
1272
1307
  // could contain just a single string (e.g. 'eachPixelABC') or
@@ -1274,6 +1309,9 @@ class FixtureService {
1274
1309
  // an array of pixel (groups)
1275
1310
  result = repeatFor;
1276
1311
  }
1312
+ else if (repeatFor.length === 0) {
1313
+ return result;
1314
+ }
1277
1315
  else if (repeatFor[0] === 'eachPixelABC') {
1278
1316
  // Gets computed into an alphanumerically sorted list of all pixelKeys
1279
1317
  if (profile.matrix.pixelCount.length === 3) {
@@ -1286,23 +1324,13 @@ class FixtureService {
1286
1324
  }
1287
1325
  }
1288
1326
  else {
1289
- for (let pixelKeyX of profile.matrix.pixelKeys) {
1290
- for (let pixelKeyY of pixelKeyX) {
1291
- for (let pixelKeyZ of pixelKeyY) {
1292
- if (pixelKeyZ) {
1293
- result.push(pixelKeyZ);
1294
- }
1295
- }
1296
- }
1297
- }
1327
+ result = result.concat(this.getAllPixelKeys(profile));
1298
1328
  }
1299
1329
  result.sort(this.alphanumericSort);
1300
1330
  }
1301
1331
  else if (repeatFor[0] === 'eachPixelGroup') {
1302
1332
  // Gets computed into an array of all pixel group keys, ordered by appearance in the JSON file
1303
- for (const property of Object.keys(profile.matrix.pixelGroups)) {
1304
- result.push(property);
1305
- }
1333
+ result = result.concat(this.getAllPixelGroups(profile));
1306
1334
  }
1307
1335
  else if (repeatFor[0] === 'eachPixelXYZ') {
1308
1336
  for (let x = 0; x < profile.matrix.pixelKeys.length; x++) {
@@ -1426,13 +1454,27 @@ class FixtureService {
1426
1454
  for (const channel of mode.channels) {
1427
1455
  if (channel.name && !pixelKey) {
1428
1456
  // direct reference to a channel
1457
+ // don't check the fine channels. only add the coarse channel.
1458
+ let channelFound = false;
1429
1459
  for (const availableChannelName of Object.keys(profile.availableChannels)) {
1430
- // don't check the fine channels. only add the coarse channel.
1431
1460
  if (channel.name === availableChannelName) {
1432
1461
  const availableChannel = profile.availableChannels[availableChannelName];
1433
1462
  this.addCachedChannel(channels, availableChannel, availableChannelName, null, profile);
1434
1463
  }
1435
1464
  }
1465
+ // check the template channels, if not found in the available channels
1466
+ if (!channelFound) {
1467
+ for (const templateChannelName of Object.keys(profile.templateChannels)) {
1468
+ let existingPixelKeys = this.getAllPixelKeys(profile).concat(this.getAllPixelGroups(profile));
1469
+ for (const existingPixelKey of existingPixelKeys) {
1470
+ const channelName = this.getChannelNameWithPixelKey(templateChannelName, existingPixelKey);
1471
+ if (channel.name === channelName) {
1472
+ const templateChannel = profile.templateChannels[templateChannelName];
1473
+ this.addCachedChannel(channels, templateChannel, channelName, existingPixelKey, profile);
1474
+ }
1475
+ }
1476
+ }
1477
+ }
1436
1478
  }
1437
1479
  else {
1438
1480
  // reference a channel through a pixel matrix
@@ -1479,28 +1521,30 @@ class FixtureService {
1479
1521
  let mode = this.getModeByFixture(profile, fixture);
1480
1522
  // add the unique pixel keys
1481
1523
  for (let channel of mode.channels) {
1482
- this.getPixelKeysInOrder(profile, channel.repeatFor).forEach((str) => pixelKeys.add(str));
1524
+ this.getPixelKeysInOrder(profile, channel.repeatFor).forEach((str) => {
1525
+ pixelKeys.add(str);
1526
+ });
1483
1527
  }
1484
1528
  return Array.from(pixelKeys);
1485
1529
  }
1530
+ // does the fixture have a general channel without reference to specific pixel keys in the current mode?
1531
+ fixtureHasGeneralChannel(fixture) {
1532
+ let profile = this.getProfileByUuid(fixture.profileUuid);
1533
+ let mode = this.getModeByFixture(profile, fixture);
1534
+ // add the unique pixel keys
1535
+ for (let channel of mode.channels) {
1536
+ if (this.getPixelKeysInOrder(profile, channel.repeatFor).length === 0) {
1537
+ return true;
1538
+ }
1539
+ }
1540
+ return false;
1541
+ }
1486
1542
  updateCachedFixtures() {
1487
1543
  // calculate some frequently used values as a cache to save cpu time
1488
1544
  // afterwards
1489
1545
  this.cachedFixtures = [];
1490
1546
  for (const fixture of this.projectService.project.fixtures) {
1491
- const pixelKeys = this.fixtureGetUniquePixelKeys(fixture);
1492
- if (pixelKeys.length > 0) {
1493
- for (let pixelKey of pixelKeys) {
1494
- const cachedFixture = new CachedFixture();
1495
- cachedFixture.fixture = fixture;
1496
- cachedFixture.pixelKey = pixelKey;
1497
- cachedFixture.profile = this.getProfileByUuid(fixture.profileUuid);
1498
- cachedFixture.mode = this.getModeByFixture(cachedFixture.profile, fixture);
1499
- cachedFixture.channels = this.getCachedChannels(cachedFixture.profile, cachedFixture.mode, pixelKey);
1500
- this.cachedFixtures.push(cachedFixture);
1501
- }
1502
- }
1503
- else {
1547
+ if (this.fixtureHasGeneralChannel(fixture)) {
1504
1548
  const cachedFixture = new CachedFixture();
1505
1549
  cachedFixture.fixture = fixture;
1506
1550
  cachedFixture.profile = this.getProfileByUuid(fixture.profileUuid);
@@ -1508,6 +1552,16 @@ class FixtureService {
1508
1552
  cachedFixture.channels = this.getCachedChannels(cachedFixture.profile, cachedFixture.mode, null);
1509
1553
  this.cachedFixtures.push(cachedFixture);
1510
1554
  }
1555
+ const pixelKeys = this.fixtureGetUniquePixelKeys(fixture);
1556
+ for (let pixelKey of pixelKeys) {
1557
+ const cachedFixture = new CachedFixture();
1558
+ cachedFixture.fixture = fixture;
1559
+ cachedFixture.pixelKey = pixelKey;
1560
+ cachedFixture.profile = this.getProfileByUuid(fixture.profileUuid);
1561
+ cachedFixture.mode = this.getModeByFixture(cachedFixture.profile, fixture);
1562
+ cachedFixture.channels = this.getCachedChannels(cachedFixture.profile, cachedFixture.mode, pixelKey);
1563
+ this.cachedFixtures.push(cachedFixture);
1564
+ }
1511
1565
  }
1512
1566
  }
1513
1567
  capabilitiesMatch(type1, type2, color1, color2, wheel1, wheel2, profileUuid1, profileUuid2) {
@@ -1766,9 +1820,12 @@ class PresetService {
1766
1820
  }
1767
1821
  }
1768
1822
  }
1823
+ fixtureUuidAndPixelKeyEquals(fixtureUuid1, fixtureUuid2, pixelKey1, pixelKey2) {
1824
+ return fixtureUuid1 === fixtureUuid2 && ((!pixelKey1 && !pixelKey2) || pixelKey1 === pixelKey2);
1825
+ }
1769
1826
  getPresetFixture(preset, fixtureUuid, pixelKey) {
1770
1827
  for (const fixture of preset.fixtures) {
1771
- if (fixture.fixtureUuid === fixtureUuid && ((!fixture.pixelKey && !pixelKey) || fixture.pixelKey === pixelKey)) {
1828
+ if (this.fixtureUuidAndPixelKeyEquals(fixture.fixtureUuid, fixtureUuid, fixture.pixelKey, pixelKey)) {
1772
1829
  return fixture;
1773
1830
  }
1774
1831
  }
@@ -1824,21 +1881,19 @@ class PresetService {
1824
1881
  return;
1825
1882
  }
1826
1883
  for (const fixture of this.projectService.project.fixtures) {
1827
- const pixelKeys = this.fixtureService.fixtureGetUniquePixelKeys(fixture);
1828
- if (pixelKeys.length > 0) {
1829
- for (const pixelKey of pixelKeys) {
1830
- if (!this.fixtureIsSelected(fixture, pixelKey)) {
1831
- const presetFixture = new PresetFixture();
1832
- presetFixture.fixtureUuid = fixture.uuid;
1833
- presetFixture.pixelKey = pixelKey;
1834
- this.selectedPreset.fixtures.push(presetFixture);
1835
- }
1884
+ if (this.fixtureService.fixtureHasGeneralChannel(fixture)) {
1885
+ if (!this.fixtureIsSelected(fixture, null)) {
1886
+ const presetFixture = new PresetFixture();
1887
+ presetFixture.fixtureUuid = fixture.uuid;
1888
+ this.selectedPreset.fixtures.push(presetFixture);
1836
1889
  }
1837
1890
  }
1838
- else {
1839
- if (!this.fixtureIsSelected(fixture, null)) {
1891
+ const pixelKeys = this.fixtureService.fixtureGetUniquePixelKeys(fixture);
1892
+ for (const pixelKey of pixelKeys) {
1893
+ if (!this.fixtureIsSelected(fixture, pixelKey)) {
1840
1894
  const presetFixture = new PresetFixture();
1841
1895
  presetFixture.fixtureUuid = fixture.uuid;
1896
+ presetFixture.pixelKey = pixelKey;
1842
1897
  this.selectedPreset.fixtures.push(presetFixture);
1843
1898
  }
1844
1899
  }
@@ -3120,29 +3175,34 @@ class PreviewService {
3120
3175
  getFixtureIndex(preset, fixtureUuid, pixelKey) {
3121
3176
  let index = 0;
3122
3177
  const countedFirstDmxChannelPixelKey = [];
3178
+ if (!this.presetService.getPresetFixture(preset, fixtureUuid, pixelKey)) {
3179
+ // fixture is not in preset
3180
+ return undefined;
3181
+ }
3123
3182
  // Loop over the global fixtures to retain the order
3124
3183
  for (const projectFixture of this.projectService.project.presetFixtures) {
3125
- const presetFixture = this.presetService.getPresetFixture(preset, fixtureUuid, pixelKey);
3126
- if (!presetFixture) {
3127
- // Not found in the preset
3128
- return undefined;
3129
- }
3130
- if (projectFixture.fixtureUuid === fixtureUuid && ((!projectFixture.pixelKey && !pixelKey) || projectFixture.pixelKey === pixelKey)) {
3131
- return index;
3132
- }
3133
- const fixture = this.fixtureService.getFixtureByUuid(projectFixture.fixtureUuid);
3134
- const firstDmxChannelAndFixtureUuid = {
3135
- firstDmxChannel: fixture.dmxFirstChannel,
3136
- pixelKey: projectFixture.pixelKey,
3137
- };
3138
- const exists = countedFirstDmxChannelPixelKey.some((item) => item.firstDmxChannel === firstDmxChannelAndFixtureUuid.firstDmxChannel &&
3139
- ((!item.pixelKey && !firstDmxChannelAndFixtureUuid.pixelKey) || item.pixelKey === firstDmxChannelAndFixtureUuid.pixelKey));
3140
- // don't count fixtures on the same channel as already counted ones
3141
- if (!exists) {
3142
- index++;
3143
- countedFirstDmxChannelPixelKey.push(firstDmxChannelAndFixtureUuid);
3184
+ for (const presetFixture of preset.fixtures) {
3185
+ if (this.presetService.fixtureUuidAndPixelKeyEquals(projectFixture.fixtureUuid, presetFixture.fixtureUuid, projectFixture.pixelKey, presetFixture.pixelKey)) {
3186
+ if (this.presetService.fixtureUuidAndPixelKeyEquals(projectFixture.fixtureUuid, fixtureUuid, projectFixture.pixelKey, pixelKey)) {
3187
+ return index;
3188
+ }
3189
+ const fixture = this.fixtureService.getFixtureByUuid(projectFixture.fixtureUuid);
3190
+ const firstDmxChannelAndFixtureUuid = {
3191
+ firstDmxChannel: fixture.dmxFirstChannel,
3192
+ pixelKey: projectFixture.pixelKey,
3193
+ };
3194
+ const exists = countedFirstDmxChannelPixelKey.some((item) => item.firstDmxChannel === firstDmxChannelAndFixtureUuid.firstDmxChannel &&
3195
+ ((!item.pixelKey && !firstDmxChannelAndFixtureUuid.pixelKey) || item.pixelKey === firstDmxChannelAndFixtureUuid.pixelKey));
3196
+ // don't count fixtures on the same channel as already counted ones
3197
+ if (!exists) {
3198
+ index++;
3199
+ countedFirstDmxChannelPixelKey.push(firstDmxChannelAndFixtureUuid);
3200
+ }
3201
+ break;
3202
+ }
3144
3203
  }
3145
3204
  }
3205
+ return undefined;
3146
3206
  }
3147
3207
  getPresetIntensity(preset, timeMillis) {
3148
3208
  // When fading is in progress (on preset or scene-level), the current preset does not
@@ -3375,43 +3435,6 @@ class PreviewService {
3375
3435
  }
3376
3436
  return calculatedFixtures;
3377
3437
  }
3378
- setUniverseValues(fixtures, masterDimmerValue) {
3379
- // TODO only, if monitoring is enabled
3380
- return;
3381
- // // Reset all DMX universes
3382
- // for (const universe of this.universeService.universes) {
3383
- // universe.channelValues = [];
3384
- // for (let i = 0; i < 512; i++) {
3385
- // universe.channelValues.push(0);
3386
- // }
3387
- // }
3388
- // // loop over each fixture
3389
- // fixtures.forEach((channelValues: FixtureChannelValue[], cachedFixture: CachedFixture) => {
3390
- // // TODO Get the correct universe for this fixture
3391
- // const universe: Universe = this.universeService.getUniverseByUuid(cachedFixture.fixture.dmxUniverseUuid);
3392
- // // loop over each channel for this fixture
3393
- // for (let channelIndex = 0; channelIndex < cachedFixture.mode.channels.length; channelIndex++) {
3394
- // const channelObj = cachedFixture.mode.channels[channelIndex];
3395
- // if (typeof channelObj === 'string') {
3396
- // const channelName = channelObj;
3397
- // // match this mode channel with a channel value
3398
- // for (const channelValue of channelValues) {
3399
- // const channel = this.fixtureService.getChannelByName(cachedFixture, channelName);
3400
- // if (channel && channel.channel) {
3401
- // const fineIndex = channel.channel.fineChannelAliases.indexOf(channelName);
3402
- // if (channel.name === channelValue.channelName || fineIndex > -1) {
3403
- // const universeChannel = cachedFixture.fixture.dmxFirstChannel + channelIndex;
3404
- // const dmxValue =
3405
- // Math.floor(channelValue.value / Math.pow(256, channel.channel.fineChannelAliases.length - (fineIndex + 1))) % 256;
3406
- // // TODO
3407
- // break;
3408
- // }
3409
- // }
3410
- // }
3411
- // }
3412
- // }
3413
- // });
3414
- }
3415
3438
  fixtureIsSelected(uuid, pixelKey, presets) {
3416
3439
  for (const preset of presets) {
3417
3440
  if (this.presetService.getPresetFixture(preset.preset, uuid, pixelKey)) {
@@ -4047,8 +4070,6 @@ class PreviewComponent {
4047
4070
  fixture3d.isSelected = this.previewService.fixtureIsSelected(fixture3d.fixture.fixture.uuid, fixture3d.fixture.pixelKey, presets);
4048
4071
  }
4049
4072
  }
4050
- // TODO enable for monitoring the DMX universes
4051
- this.previewService.setUniverseValues(calculatedFixtures, this.projectService.project.masterDimmerValue);
4052
4073
  // Render the scene
4053
4074
  this.render();
4054
4075
  requestAnimationFrame(this.animate.bind(this));
@@ -4282,39 +4303,36 @@ class ProjectLoadService {
4282
4303
  }
4283
4304
  migrateToVersion2() {
4284
4305
  for (let fixture of this.projectService.project.fixtures) {
4285
- const pixelKeys = this.fixtureService.fixtureGetUniquePixelKeys(fixture);
4286
- if (pixelKeys.length > 0) {
4287
- for (let pixelKey of pixelKeys) {
4288
- const projectFixture = new PresetFixture();
4289
- projectFixture.fixtureUuid = fixture.uuid;
4290
- projectFixture.pixelKey = pixelKey;
4291
- this.projectService.project.presetFixtures.push(projectFixture);
4292
- }
4306
+ if (this.fixtureService.fixtureHasGeneralChannel(fixture)) {
4307
+ const projectFixture = new PresetFixture();
4308
+ projectFixture.fixtureUuid = fixture.uuid;
4309
+ this.projectService.project.presetFixtures.push(projectFixture);
4293
4310
  }
4294
- else {
4311
+ const pixelKeys = this.fixtureService.fixtureGetUniquePixelKeys(fixture);
4312
+ for (let pixelKey of pixelKeys) {
4295
4313
  const projectFixture = new PresetFixture();
4296
4314
  projectFixture.fixtureUuid = fixture.uuid;
4315
+ projectFixture.pixelKey = pixelKey;
4297
4316
  this.projectService.project.presetFixtures.push(projectFixture);
4298
4317
  }
4299
4318
  }
4300
4319
  for (let preset of this.projectService.project.presets) {
4301
4320
  for (let fixtureUuid of preset.fixtureUuids) {
4302
4321
  const fixture = this.fixtureService.getFixtureByUuid(fixtureUuid);
4303
- const pixelKeys = this.fixtureService.fixtureGetUniquePixelKeys(fixture);
4304
- if (pixelKeys.length > 0) {
4305
- for (let pixelKey of pixelKeys) {
4306
- const presetFixture = new PresetFixture();
4307
- presetFixture.fixtureUuid = fixtureUuid;
4308
- presetFixture.pixelKey = pixelKey;
4309
- preset.fixtures.push(presetFixture);
4310
- }
4322
+ if (this.fixtureService.fixtureHasGeneralChannel(fixture)) {
4323
+ const presetFixture = new PresetFixture();
4324
+ presetFixture.fixtureUuid = fixtureUuid;
4325
+ preset.fixtures.push(presetFixture);
4311
4326
  }
4312
- else {
4327
+ const pixelKeys = this.fixtureService.fixtureGetUniquePixelKeys(fixture);
4328
+ for (let pixelKey of pixelKeys) {
4313
4329
  const presetFixture = new PresetFixture();
4314
4330
  presetFixture.fixtureUuid = fixtureUuid;
4331
+ presetFixture.pixelKey = pixelKey;
4315
4332
  preset.fixtures.push(presetFixture);
4316
4333
  }
4317
4334
  }
4335
+ preset.fixtureUuids = undefined;
4318
4336
  }
4319
4337
  this.projectService.project.version = 2;
4320
4338
  }
@@ -5578,18 +5596,16 @@ class FixturePoolComponent {
5578
5596
  }
5579
5597
  }
5580
5598
  if (!found) {
5581
- const pixelKeys = this.fixtureService.fixtureGetUniquePixelKeys(fixture);
5582
- if (pixelKeys.length > 0) {
5583
- for (let pixelKey of pixelKeys) {
5584
- const presetFixture = new PresetFixture();
5585
- presetFixture.fixtureUuid = fixture.uuid;
5586
- presetFixture.pixelKey = pixelKey;
5587
- this.projectService.project.presetFixtures.push(presetFixture);
5588
- }
5599
+ if (this.fixtureService.fixtureHasGeneralChannel(fixture)) {
5600
+ const presetFixture = new PresetFixture();
5601
+ presetFixture.fixtureUuid = fixture.uuid;
5602
+ this.projectService.project.presetFixtures.push(presetFixture);
5589
5603
  }
5590
- else {
5604
+ const pixelKeys = this.fixtureService.fixtureGetUniquePixelKeys(fixture);
5605
+ for (let pixelKey of pixelKeys) {
5591
5606
  const presetFixture = new PresetFixture();
5592
5607
  presetFixture.fixtureUuid = fixture.uuid;
5608
+ presetFixture.pixelKey = pixelKey;
5593
5609
  this.projectService.project.presetFixtures.push(presetFixture);
5594
5610
  }
5595
5611
  }