@playcanvas/web-components 0.1.6 → 0.1.8

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/pwc.cjs CHANGED
@@ -259,6 +259,157 @@ class AppElement extends AsyncElement {
259
259
  }
260
260
  customElements.define('pc-app', AppElement);
261
261
 
262
+ const CSS_COLORS = {
263
+ aliceblue: '#f0f8ff',
264
+ antiquewhite: '#faebd7',
265
+ aqua: '#00ffff',
266
+ aquamarine: '#7fffd4',
267
+ azure: '#f0ffff',
268
+ beige: '#f5f5dc',
269
+ bisque: '#ffe4c4',
270
+ black: '#000000',
271
+ blanchedalmond: '#ffebcd',
272
+ blue: '#0000ff',
273
+ blueviolet: '#8a2be2',
274
+ brown: '#a52a2a',
275
+ burlywood: '#deb887',
276
+ cadetblue: '#5f9ea0',
277
+ chartreuse: '#7fff00',
278
+ chocolate: '#d2691e',
279
+ coral: '#ff7f50',
280
+ cornflowerblue: '#6495ed',
281
+ cornsilk: '#fff8dc',
282
+ crimson: '#dc143c',
283
+ cyan: '#00ffff',
284
+ darkblue: '#00008b',
285
+ darkcyan: '#008b8b',
286
+ darkgoldenrod: '#b8860b',
287
+ darkgray: '#a9a9a9',
288
+ darkgreen: '#006400',
289
+ darkgrey: '#a9a9a9',
290
+ darkkhaki: '#bdb76b',
291
+ darkmagenta: '#8b008b',
292
+ darkolivegreen: '#556b2f',
293
+ darkorange: '#ff8c00',
294
+ darkorchid: '#9932cc',
295
+ darkred: '#8b0000',
296
+ darksalmon: '#e9967a',
297
+ darkseagreen: '#8fbc8f',
298
+ darkslateblue: '#483d8b',
299
+ darkslategray: '#2f4f4f',
300
+ darkslategrey: '#2f4f4f',
301
+ darkturquoise: '#00ced1',
302
+ darkviolet: '#9400d3',
303
+ deeppink: '#ff1493',
304
+ deepskyblue: '#00bfff',
305
+ dimgray: '#696969',
306
+ dimgrey: '#696969',
307
+ dodgerblue: '#1e90ff',
308
+ firebrick: '#b22222',
309
+ floralwhite: '#fffaf0',
310
+ forestgreen: '#228b22',
311
+ fuchsia: '#ff00ff',
312
+ gainsboro: '#dcdcdc',
313
+ ghostwhite: '#f8f8ff',
314
+ gold: '#ffd700',
315
+ goldenrod: '#daa520',
316
+ gray: '#808080',
317
+ green: '#008000',
318
+ greenyellow: '#adff2f',
319
+ grey: '#808080',
320
+ honeydew: '#f0fff0',
321
+ hotpink: '#ff69b4',
322
+ indianred: '#cd5c5c',
323
+ indigo: '#4b0082',
324
+ ivory: '#fffff0',
325
+ khaki: '#f0e68c',
326
+ lavender: '#e6e6fa',
327
+ lavenderblush: '#fff0f5',
328
+ lawngreen: '#7cfc00',
329
+ lemonchiffon: '#fffacd',
330
+ lightblue: '#add8e6',
331
+ lightcoral: '#f08080',
332
+ lightcyan: '#e0ffff',
333
+ lightgoldenrodyellow: '#fafad2',
334
+ lightgray: '#d3d3d3',
335
+ lightgreen: '#90ee90',
336
+ lightgrey: '#d3d3d3',
337
+ lightpink: '#ffb6c1',
338
+ lightsalmon: '#ffa07a',
339
+ lightseagreen: '#20b2aa',
340
+ lightskyblue: '#87cefa',
341
+ lightslategray: '#778899',
342
+ lightslategrey: '#778899',
343
+ lightsteelblue: '#b0c4de',
344
+ lightyellow: '#ffffe0',
345
+ lime: '#00ff00',
346
+ limegreen: '#32cd32',
347
+ linen: '#faf0e6',
348
+ magenta: '#ff00ff',
349
+ maroon: '#800000',
350
+ mediumaquamarine: '#66cdaa',
351
+ mediumblue: '#0000cd',
352
+ mediumorchid: '#ba55d3',
353
+ mediumpurple: '#9370db',
354
+ mediumseagreen: '#3cb371',
355
+ mediumslateblue: '#7b68ee',
356
+ mediumspringgreen: '#00fa9a',
357
+ mediumturquoise: '#48d1cc',
358
+ mediumvioletred: '#c71585',
359
+ midnightblue: '#191970',
360
+ mintcream: '#f5fffa',
361
+ mistyrose: '#ffe4e1',
362
+ moccasin: '#ffe4b5',
363
+ navajowhite: '#ffdead',
364
+ navy: '#000080',
365
+ oldlace: '#fdf5e6',
366
+ olive: '#808000',
367
+ olivedrab: '#6b8e23',
368
+ orange: '#ffa500',
369
+ orangered: '#ff4500',
370
+ orchid: '#da70d6',
371
+ palegoldenrod: '#eee8aa',
372
+ palegreen: '#98fb98',
373
+ paleturquoise: '#afeeee',
374
+ palevioletred: '#db7093',
375
+ papayawhip: '#ffefd5',
376
+ peachpuff: '#ffdab9',
377
+ peru: '#cd853f',
378
+ pink: '#ffc0cb',
379
+ plum: '#dda0dd',
380
+ powderblue: '#b0e0e6',
381
+ purple: '#800080',
382
+ rebeccapurple: '#663399',
383
+ red: '#ff0000',
384
+ rosybrown: '#bc8f8f',
385
+ royalblue: '#4169e1',
386
+ saddlebrown: '#8b4513',
387
+ salmon: '#fa8072',
388
+ sandybrown: '#f4a460',
389
+ seagreen: '#2e8b57',
390
+ seashell: '#fff5ee',
391
+ sienna: '#a0522d',
392
+ silver: '#c0c0c0',
393
+ skyblue: '#87ceeb',
394
+ slateblue: '#6a5acd',
395
+ slategray: '#708090',
396
+ slategrey: '#708090',
397
+ snow: '#fffafa',
398
+ springgreen: '#00ff7f',
399
+ steelblue: '#4682b4',
400
+ tan: '#d2b48c',
401
+ teal: '#008080',
402
+ thistle: '#d8bfd8',
403
+ tomato: '#ff6347',
404
+ turquoise: '#40e0d0',
405
+ violet: '#ee82ee',
406
+ wheat: '#f5deb3',
407
+ white: '#ffffff',
408
+ whitesmoke: '#f5f5f5',
409
+ yellow: '#ffff00',
410
+ yellowgreen: '#9acd32'
411
+ };
412
+
262
413
  /**
263
414
  * Parse a color string into a Color object. String can be in the format of '#rgb', '#rgba',
264
415
  * '#rrggbb', '#rrggbbaa', or a string of 3 or 4 comma-delimited numbers.
@@ -267,10 +418,15 @@ customElements.define('pc-app', AppElement);
267
418
  * @returns The parsed Color object.
268
419
  */
269
420
  const parseColor = (value) => {
421
+ // Check if it's a CSS color name first
422
+ const hexColor = CSS_COLORS[value.toLowerCase()];
423
+ if (hexColor) {
424
+ return new playcanvas.Color().fromString(hexColor);
425
+ }
270
426
  if (value.startsWith('#')) {
271
427
  return new playcanvas.Color().fromString(value);
272
428
  }
273
- const components = value.split(',').map(Number);
429
+ const components = value.split(' ').map(Number);
274
430
  return new playcanvas.Color(components);
275
431
  };
276
432
  /**
@@ -280,7 +436,7 @@ const parseColor = (value) => {
280
436
  * @returns The parsed Quat object.
281
437
  */
282
438
  const parseQuat = (value) => {
283
- const [x, y, z] = value.split(',').map(Number);
439
+ const [x, y, z] = value.split(' ').map(Number);
284
440
  const q = new playcanvas.Quat();
285
441
  q.setFromEulerAngles(x, y, z);
286
442
  return q;
@@ -292,7 +448,7 @@ const parseQuat = (value) => {
292
448
  * @returns The parsed Vec2 object.
293
449
  */
294
450
  const parseVec2 = (value) => {
295
- const components = value.split(',').map(Number);
451
+ const components = value.split(' ').map(Number);
296
452
  return new playcanvas.Vec2(components);
297
453
  };
298
454
  /**
@@ -302,7 +458,7 @@ const parseVec2 = (value) => {
302
458
  * @returns The parsed Vec3 object.
303
459
  */
304
460
  const parseVec3 = (value) => {
305
- const components = value.split(',').map(Number);
461
+ const components = value.split(' ').map(Number);
306
462
  return new playcanvas.Vec3(components);
307
463
  };
308
464
  /**
@@ -312,7 +468,7 @@ const parseVec3 = (value) => {
312
468
  * @returns The parsed Vec4 object.
313
469
  */
314
470
  const parseVec4 = (value) => {
315
- const components = value.split(',').map(Number);
471
+ const components = value.split(' ').map(Number);
316
472
  return new playcanvas.Vec4(components);
317
473
  };
318
474
 
@@ -361,11 +517,14 @@ class EntityElement extends AsyncElement {
361
517
  // Create a new entity
362
518
  this.entity = new playcanvas.Entity(this._name, app);
363
519
  // Initialize from attributes
520
+ const enabledAttr = this.getAttribute('enabled');
364
521
  const nameAttr = this.getAttribute('name');
365
522
  const positionAttr = this.getAttribute('position');
366
523
  const rotationAttr = this.getAttribute('rotation');
367
524
  const scaleAttr = this.getAttribute('scale');
368
525
  const tagsAttr = this.getAttribute('tags');
526
+ if (enabledAttr)
527
+ this.enabled = enabledAttr !== 'false';
369
528
  if (nameAttr)
370
529
  this.name = nameAttr;
371
530
  if (positionAttr)
@@ -1537,6 +1696,7 @@ class LightComponentElement extends ComponentElement {
1537
1696
  this._range = 10;
1538
1697
  this._shadowBias = 0.2;
1539
1698
  this._shadowDistance = 16;
1699
+ this._shadowResolution = 1024;
1540
1700
  this._type = 'directional';
1541
1701
  }
1542
1702
  getInitialComponentData() {
@@ -1550,6 +1710,7 @@ class LightComponentElement extends ComponentElement {
1550
1710
  range: this._range,
1551
1711
  shadowBias: this._shadowBias,
1552
1712
  shadowDistance: this._shadowDistance,
1713
+ shadowResolution: this._shadowResolution,
1553
1714
  type: this._type
1554
1715
  };
1555
1716
  }
@@ -1713,6 +1874,23 @@ class LightComponentElement extends ComponentElement {
1713
1874
  get shadowDistance() {
1714
1875
  return this._shadowDistance;
1715
1876
  }
1877
+ /**
1878
+ * Sets the shadow resolution of the light.
1879
+ * @param value - The shadow resolution.
1880
+ */
1881
+ set shadowResolution(value) {
1882
+ this._shadowResolution = value;
1883
+ if (this.component) {
1884
+ this.component.shadowResolution = value;
1885
+ }
1886
+ }
1887
+ /**
1888
+ * Gets the shadow resolution of the light.
1889
+ * @returns The shadow resolution.
1890
+ */
1891
+ get shadowResolution() {
1892
+ return this._shadowResolution;
1893
+ }
1716
1894
  /**
1717
1895
  * Sets the type of the light.
1718
1896
  * @param value - The type.
@@ -1746,6 +1924,7 @@ class LightComponentElement extends ComponentElement {
1746
1924
  'range',
1747
1925
  'shadow-bias',
1748
1926
  'shadow-distance',
1927
+ 'shadow-resolution',
1749
1928
  'type'
1750
1929
  ];
1751
1930
  }
@@ -1779,6 +1958,9 @@ class LightComponentElement extends ComponentElement {
1779
1958
  case 'shadow-distance':
1780
1959
  this.shadowDistance = Number(newValue);
1781
1960
  break;
1961
+ case 'shadow-resolution':
1962
+ this.shadowResolution = Number(newValue);
1963
+ break;
1782
1964
  case 'type':
1783
1965
  this.type = newValue;
1784
1966
  break;
@@ -2362,23 +2544,47 @@ class ScriptComponentElement extends ComponentElement {
2362
2544
  }
2363
2545
  applyAttributes(script, attributes) {
2364
2546
  try {
2365
- // Parse the attributes string into an object and set them on the script
2366
2547
  const attributesObject = attributes ? JSON.parse(attributes) : {};
2367
- for (const key in attributesObject) {
2368
- const value = attributesObject[key];
2369
- if (Array.isArray(value) && script[key] instanceof playcanvas.Vec2) {
2370
- script[key] = tmpV2.set(value[0], value[1]);
2371
- continue;
2548
+ const applyValue = (target, key, value) => {
2549
+ // Handle asset references
2550
+ if (typeof value === 'string' && value.startsWith('asset:')) {
2551
+ const assetId = value.slice(6);
2552
+ const assetElement = document.querySelector(`pc-asset#${assetId}`);
2553
+ if (assetElement) {
2554
+ target[key] = assetElement.asset;
2555
+ return;
2556
+ }
2557
+ }
2558
+ // Handle vectors
2559
+ if (Array.isArray(value)) {
2560
+ if (target[key] instanceof playcanvas.Vec2) {
2561
+ target[key] = tmpV2.set(value[0], value[1]);
2562
+ return;
2563
+ }
2564
+ if (target[key] instanceof playcanvas.Vec3) {
2565
+ target[key] = tmpV3.set(value[0], value[1], value[2]);
2566
+ return;
2567
+ }
2568
+ if (target[key] instanceof playcanvas.Vec4) {
2569
+ target[key] = tmpV4.set(value[0], value[1], value[2], value[3]);
2570
+ return;
2571
+ }
2372
2572
  }
2373
- if (Array.isArray(value) && script[key] instanceof playcanvas.Vec3) {
2374
- script[key] = tmpV3.set(value[0], value[1], value[2]);
2375
- continue;
2573
+ // Handle nested objects
2574
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
2575
+ if (!target[key] || typeof target[key] !== 'object') {
2576
+ target[key] = {};
2577
+ }
2578
+ for (const nestedKey in value) {
2579
+ applyValue(target[key], nestedKey, value[nestedKey]);
2580
+ }
2376
2581
  }
2377
- if (Array.isArray(value) && script[key] instanceof playcanvas.Vec4) {
2378
- script[key] = tmpV4.set(value[0], value[1], value[2], value[3]);
2379
- continue;
2582
+ else {
2583
+ target[key] = value;
2380
2584
  }
2381
- script[key] = value;
2585
+ };
2586
+ for (const key in attributesObject) {
2587
+ applyValue(script, key, attributesObject[key]);
2382
2588
  }
2383
2589
  }
2384
2590
  catch (error) {
@@ -2977,48 +3183,71 @@ class ModelElement extends AsyncElement {
2977
3183
  constructor() {
2978
3184
  super(...arguments);
2979
3185
  this._asset = '';
3186
+ this._entity = null;
2980
3187
  }
2981
- async connectedCallback() {
2982
- var _a;
2983
- await ((_a = this.closestApp) === null || _a === void 0 ? void 0 : _a.ready());
2984
- const asset = this.getAttribute('asset');
2985
- if (asset) {
2986
- this.asset = asset;
2987
- }
3188
+ connectedCallback() {
3189
+ this._loadModel();
2988
3190
  this._onReady();
2989
3191
  }
2990
- _loadModel() {
2991
- const asset = AssetElement.get(this._asset);
2992
- if (!asset) {
2993
- return;
2994
- }
2995
- const entity = asset.resource.instantiateRenderEntity();
2996
- if (asset.resource.animations.length > 0) {
2997
- entity.addComponent('anim');
2998
- entity.anim.assignAnimation('animation', asset.resource.animations[0].resource);
3192
+ disconnectedCallback() {
3193
+ this._unloadModel();
3194
+ }
3195
+ _instantiate(container) {
3196
+ this._entity = container.instantiateRenderEntity();
3197
+ // @ts-ignore
3198
+ if (container.animations.length > 0) {
3199
+ this._entity.addComponent('anim');
3200
+ // @ts-ignore
3201
+ this._entity.anim.assignAnimation('animation', container.animations[0].resource);
2999
3202
  }
3000
3203
  const parentEntityElement = this.closestEntity;
3001
3204
  if (parentEntityElement) {
3002
3205
  parentEntityElement.ready().then(() => {
3003
- parentEntityElement.entity.addChild(entity);
3206
+ parentEntityElement.entity.addChild(this._entity);
3004
3207
  });
3005
3208
  }
3006
3209
  else {
3007
3210
  const appElement = this.closestApp;
3008
3211
  if (appElement) {
3009
3212
  appElement.ready().then(() => {
3010
- appElement.app.root.addChild(entity);
3213
+ appElement.app.root.addChild(this._entity);
3011
3214
  });
3012
3215
  }
3013
3216
  }
3014
3217
  }
3218
+ async _loadModel() {
3219
+ var _a;
3220
+ this._unloadModel();
3221
+ const appElement = await ((_a = this.closestApp) === null || _a === void 0 ? void 0 : _a.ready());
3222
+ const app = appElement === null || appElement === void 0 ? void 0 : appElement.app;
3223
+ const asset = AssetElement.get(this._asset);
3224
+ if (!asset) {
3225
+ return;
3226
+ }
3227
+ if (asset.loaded) {
3228
+ this._instantiate(asset.resource);
3229
+ }
3230
+ else {
3231
+ asset.once('load', () => {
3232
+ this._instantiate(asset.resource);
3233
+ });
3234
+ app.assets.load(asset);
3235
+ }
3236
+ }
3237
+ _unloadModel() {
3238
+ var _a;
3239
+ (_a = this._entity) === null || _a === void 0 ? void 0 : _a.destroy();
3240
+ this._entity = null;
3241
+ }
3015
3242
  /**
3016
3243
  * Sets the asset ID of the model.
3017
3244
  * @param value - The asset ID.
3018
3245
  */
3019
3246
  set asset(value) {
3020
3247
  this._asset = value;
3021
- this._loadModel();
3248
+ if (this.isConnected) {
3249
+ this._loadModel();
3250
+ }
3022
3251
  }
3023
3252
  /**
3024
3253
  * Gets the source URL of the model.
@@ -3210,48 +3439,77 @@ class SkyElement extends AsyncElement {
3210
3439
  this._intensity = 1;
3211
3440
  this._rotation = new playcanvas.Vec3();
3212
3441
  this._level = 0;
3442
+ this._lighting = false;
3213
3443
  this._scale = new playcanvas.Vec3(100, 100, 100);
3214
3444
  this._type = 'infinite';
3445
+ this._scene = null;
3215
3446
  }
3216
- async connectedCallback() {
3217
- var _a;
3218
- await ((_a = this.closestApp) === null || _a === void 0 ? void 0 : _a.ready());
3219
- this.asset = this.getAttribute('asset') || '';
3447
+ connectedCallback() {
3448
+ this._loadSkybox();
3220
3449
  this._onReady();
3221
3450
  }
3222
- getScene() {
3223
- const app = this.closestApp.app;
3451
+ disconnectedCallback() {
3452
+ this._unloadSkybox();
3453
+ }
3454
+ _generateSkybox(asset) {
3455
+ if (!this._scene)
3456
+ return;
3457
+ const source = asset.resource;
3458
+ const skybox = playcanvas.EnvLighting.generateSkyboxCubemap(source);
3459
+ skybox.anisotropy = 4;
3460
+ this._scene.skybox = skybox;
3461
+ if (this._lighting) {
3462
+ const lighting = playcanvas.EnvLighting.generateLightingSource(source);
3463
+ const envAtlas = playcanvas.EnvLighting.generateAtlas(lighting);
3464
+ this._scene.envAtlas = envAtlas;
3465
+ }
3466
+ const layer = this._scene.layers.getLayerById(playcanvas.LAYERID_SKYBOX);
3467
+ if (layer) {
3468
+ layer.enabled = this._type !== 'none';
3469
+ }
3470
+ this._scene.sky.type = this._type;
3471
+ this._scene.sky.node.setLocalScale(this._scale);
3472
+ this._scene.sky.center = this._center;
3473
+ this._scene.skyboxIntensity = this._intensity;
3474
+ }
3475
+ async _loadSkybox() {
3476
+ var _a;
3477
+ const appElement = await ((_a = this.closestApp) === null || _a === void 0 ? void 0 : _a.ready());
3478
+ const app = appElement === null || appElement === void 0 ? void 0 : appElement.app;
3224
3479
  if (!app) {
3225
3480
  return;
3226
3481
  }
3227
- return app.scene;
3228
- }
3229
- initSkybox(source) {
3230
- source.anisotropy = 4;
3231
- const skybox = playcanvas.EnvLighting.generateSkyboxCubemap(source);
3232
- const lighting = playcanvas.EnvLighting.generateLightingSource(source);
3233
- const envAtlas = playcanvas.EnvLighting.generateAtlas(lighting);
3234
- const app = this.closestApp.app;
3235
- if (app) {
3236
- app.scene.envAtlas = envAtlas;
3237
- app.scene.skybox = skybox;
3238
- const layer = app.scene.layers.getLayerById(playcanvas.LAYERID_SKYBOX);
3239
- if (layer) {
3240
- layer.enabled = this._type !== 'none';
3241
- }
3242
- app.scene.sky.type = this._type;
3243
- app.scene.sky.node.setLocalScale(this._scale);
3244
- app.scene.sky.center = this._center;
3482
+ const asset = AssetElement.get(this._asset);
3483
+ if (!asset) {
3484
+ return;
3485
+ }
3486
+ this._scene = app.scene;
3487
+ if (asset.loaded) {
3488
+ this._generateSkybox(asset);
3489
+ }
3490
+ else {
3491
+ asset.once('load', () => {
3492
+ this._generateSkybox(asset);
3493
+ });
3494
+ app.assets.load(asset);
3245
3495
  }
3246
3496
  }
3497
+ _unloadSkybox() {
3498
+ var _a, _b;
3499
+ if (!this._scene)
3500
+ return;
3501
+ (_a = this._scene.skybox) === null || _a === void 0 ? void 0 : _a.destroy();
3502
+ // @ts-ignore
3503
+ this._scene.skybox = null;
3504
+ (_b = this._scene.envAtlas) === null || _b === void 0 ? void 0 : _b.destroy();
3505
+ // @ts-ignore
3506
+ this._scene.envAtlas = null;
3507
+ this._scene = null;
3508
+ }
3247
3509
  set asset(value) {
3248
3510
  this._asset = value;
3249
- const scene = this.getScene();
3250
- if (scene) {
3251
- const asset = AssetElement.get(value);
3252
- if (asset) {
3253
- this.initSkybox(asset.resource);
3254
- }
3511
+ if (this.isConnected) {
3512
+ this._loadSkybox();
3255
3513
  }
3256
3514
  }
3257
3515
  get asset() {
@@ -3259,9 +3517,8 @@ class SkyElement extends AsyncElement {
3259
3517
  }
3260
3518
  set center(value) {
3261
3519
  this._center = value;
3262
- const scene = this.getScene();
3263
- if (scene) {
3264
- scene.sky.center = this._center;
3520
+ if (this._scene) {
3521
+ this._scene.sky.center = this._center;
3265
3522
  }
3266
3523
  }
3267
3524
  get center() {
@@ -3269,19 +3526,32 @@ class SkyElement extends AsyncElement {
3269
3526
  }
3270
3527
  set intensity(value) {
3271
3528
  this._intensity = value;
3272
- const scene = this.getScene();
3273
- if (scene) {
3274
- scene.skyboxIntensity = this._intensity;
3529
+ if (this._scene) {
3530
+ this._scene.skyboxIntensity = this._intensity;
3275
3531
  }
3276
3532
  }
3277
3533
  get intensity() {
3278
3534
  return this._intensity;
3279
3535
  }
3536
+ set level(value) {
3537
+ this._level = value;
3538
+ if (this._scene) {
3539
+ this._scene.skyboxMip = this._level;
3540
+ }
3541
+ }
3542
+ get level() {
3543
+ return this._level;
3544
+ }
3545
+ set lighting(value) {
3546
+ this._lighting = value;
3547
+ }
3548
+ get lighting() {
3549
+ return this._lighting;
3550
+ }
3280
3551
  set rotation(value) {
3281
3552
  this._rotation = value;
3282
- const scene = this.getScene();
3283
- if (scene) {
3284
- scene.skyboxRotation = new playcanvas.Quat().setFromEulerAngles(value);
3553
+ if (this._scene) {
3554
+ this._scene.skyboxRotation = new playcanvas.Quat().setFromEulerAngles(value);
3285
3555
  }
3286
3556
  }
3287
3557
  get rotation() {
@@ -3289,30 +3559,18 @@ class SkyElement extends AsyncElement {
3289
3559
  }
3290
3560
  set scale(value) {
3291
3561
  this._scale = value;
3292
- const scene = this.getScene();
3293
- if (scene) {
3294
- scene.sky.node.setLocalScale(this._scale);
3562
+ if (this._scene) {
3563
+ this._scene.sky.node.setLocalScale(this._scale);
3295
3564
  }
3296
3565
  }
3297
3566
  get scale() {
3298
3567
  return this._scale;
3299
3568
  }
3300
- set level(value) {
3301
- this._level = value;
3302
- const scene = this.getScene();
3303
- if (scene) {
3304
- scene.skyboxMip = this._level;
3305
- }
3306
- }
3307
- get level() {
3308
- return this._level;
3309
- }
3310
3569
  set type(value) {
3311
3570
  this._type = value;
3312
- const scene = this.getScene();
3313
- if (scene) {
3314
- scene.sky.type = this._type;
3315
- const layer = scene.layers.getLayerById(playcanvas.LAYERID_SKYBOX);
3571
+ if (this._scene) {
3572
+ this._scene.sky.type = this._type;
3573
+ const layer = this._scene.layers.getLayerById(playcanvas.LAYERID_SKYBOX);
3316
3574
  if (layer) {
3317
3575
  layer.enabled = this._type !== 'none';
3318
3576
  }
@@ -3322,7 +3580,7 @@ class SkyElement extends AsyncElement {
3322
3580
  return this._type;
3323
3581
  }
3324
3582
  static get observedAttributes() {
3325
- return ['asset', 'center', 'intensity', 'level', 'rotation', 'scale', 'type'];
3583
+ return ['asset', 'center', 'intensity', 'level', 'lighting', 'rotation', 'scale', 'type'];
3326
3584
  }
3327
3585
  attributeChangedCallback(name, _oldValue, newValue) {
3328
3586
  switch (name) {
@@ -3335,12 +3593,15 @@ class SkyElement extends AsyncElement {
3335
3593
  case 'intensity':
3336
3594
  this.intensity = parseFloat(newValue);
3337
3595
  break;
3338
- case 'rotation':
3339
- this.rotation = parseVec3(newValue);
3340
- break;
3341
3596
  case 'level':
3342
3597
  this.level = parseInt(newValue, 10);
3343
3598
  break;
3599
+ case 'lighting':
3600
+ this.lighting = this.hasAttribute(name);
3601
+ break;
3602
+ case 'rotation':
3603
+ this.rotation = parseVec3(newValue);
3604
+ break;
3344
3605
  case 'scale':
3345
3606
  this.scale = parseVec3(newValue);
3346
3607
  break;