@playcanvas/web-components 0.1.8 → 0.1.10

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.
Files changed (58) hide show
  1. package/README.md +2 -2
  2. package/dist/app.d.ts +21 -1
  3. package/dist/asset.d.ts +3 -1
  4. package/dist/async-element.d.ts +2 -1
  5. package/dist/components/camera-component.d.ts +28 -4
  6. package/dist/components/collision-component.d.ts +4 -4
  7. package/dist/components/component.d.ts +3 -1
  8. package/dist/components/element-component.d.ts +4 -1
  9. package/dist/components/gsplat-component.d.ts +4 -1
  10. package/dist/components/light-component.d.ts +50 -4
  11. package/dist/components/listener-component.d.ts +4 -1
  12. package/dist/components/render-component.d.ts +4 -1
  13. package/dist/components/rigidbody-component.d.ts +4 -4
  14. package/dist/components/screen-component.d.ts +4 -1
  15. package/dist/components/script-component.d.ts +4 -1
  16. package/dist/components/script.d.ts +3 -1
  17. package/dist/components/sound-component.d.ts +5 -2
  18. package/dist/components/sound-slot.d.ts +3 -1
  19. package/dist/entity.d.ts +14 -3
  20. package/dist/fog.d.ts +28 -0
  21. package/dist/material.d.ts +3 -1
  22. package/dist/model.d.ts +3 -1
  23. package/dist/module.d.ts +6 -0
  24. package/dist/pwc.cjs +569 -96
  25. package/dist/pwc.cjs.map +1 -1
  26. package/dist/pwc.js +569 -96
  27. package/dist/pwc.js.map +1 -1
  28. package/dist/pwc.min.js +1 -1
  29. package/dist/pwc.min.js.map +1 -1
  30. package/dist/pwc.mjs +570 -97
  31. package/dist/pwc.mjs.map +1 -1
  32. package/dist/scene.d.ts +3 -1
  33. package/dist/sky.d.ts +3 -1
  34. package/package.json +10 -9
  35. package/src/app.ts +208 -2
  36. package/src/asset.ts +3 -1
  37. package/src/async-element.ts +2 -1
  38. package/src/components/camera-component.ts +69 -7
  39. package/src/components/collision-component.ts +4 -4
  40. package/src/components/component.ts +3 -1
  41. package/src/components/element-component.ts +4 -2
  42. package/src/components/gsplat-component.ts +4 -1
  43. package/src/components/light-component.ts +107 -7
  44. package/src/components/listener-component.ts +4 -1
  45. package/src/components/render-component.ts +4 -1
  46. package/src/components/rigidbody-component.ts +4 -4
  47. package/src/components/screen-component.ts +4 -1
  48. package/src/components/script-component.ts +26 -14
  49. package/src/components/script.ts +3 -1
  50. package/src/components/sound-component.ts +4 -1
  51. package/src/components/sound-slot.ts +3 -1
  52. package/src/entity.ts +149 -32
  53. package/src/fog.ts +121 -0
  54. package/src/material.ts +5 -3
  55. package/src/model.ts +3 -1
  56. package/src/module.ts +6 -0
  57. package/src/scene.ts +13 -11
  58. package/src/sky.ts +3 -1
@@ -3,11 +3,14 @@ import { AudioListenerComponent } from 'playcanvas';
3
3
  import { ComponentElement } from './component';
4
4
 
5
5
  /**
6
- * Represents a audio listener component in the PlayCanvas engine.
6
+ * The ListenerComponentElement interface provides properties and methods for manipulating
7
+ * `<pc-listener>` elements. The ListenerComponentElement interface also inherits the properties
8
+ * and methods of the {@link HTMLElement} interface.
7
9
  *
8
10
  * @category Components
9
11
  */
10
12
  class ListenerComponentElement extends ComponentElement {
13
+ /** @ignore */
11
14
  constructor() {
12
15
  super('audiolistener');
13
16
  }
@@ -4,7 +4,9 @@ import { ComponentElement } from './component';
4
4
  import { MaterialElement } from '../material';
5
5
 
6
6
  /**
7
- * Represents a render component in the PlayCanvas engine.
7
+ * The RenderComponentElement interface provides properties and methods for manipulating
8
+ * `<pc-render>` elements. The RenderComponentElement interface also inherits the properties and
9
+ * methods of the {@link HTMLElement} interface.
8
10
  *
9
11
  * @category Components
10
12
  */
@@ -17,6 +19,7 @@ class RenderComponentElement extends ComponentElement {
17
19
 
18
20
  private _type: 'asset' | 'box' | 'capsule' | 'cone' | 'cylinder' | 'plane' | 'sphere' = 'asset';
19
21
 
22
+ /** @ignore */
20
23
  constructor() {
21
24
  super('render');
22
25
  }
@@ -4,7 +4,9 @@ import { ComponentElement } from './component';
4
4
  import { parseVec3 } from '../utils';
5
5
 
6
6
  /**
7
- * Represents a rigidbody component in the PlayCanvas engine.
7
+ * The RigidBodyComponentElement interface provides properties and methods for manipulating
8
+ * `<pc-rigidbody>` elements. The RigidBodyComponentElement interface also inherits the properties
9
+ * and methods of the {@link HTMLElement} interface.
8
10
  *
9
11
  * @category Components
10
12
  */
@@ -54,9 +56,7 @@ class RigidBodyComponentElement extends ComponentElement {
54
56
  */
55
57
  private _type: string = 'static';
56
58
 
57
- /**
58
- * Creates a new RigidBodyComponentElement.
59
- */
59
+ /** @ignore */
60
60
  constructor() {
61
61
  super('rigidbody');
62
62
  }
@@ -4,7 +4,9 @@ import { ComponentElement } from './component';
4
4
  import { parseVec2 } from '../utils';
5
5
 
6
6
  /**
7
- * Represents a screen component in the PlayCanvas engine.
7
+ * The ScreenComponentElement interface provides properties and methods for manipulating
8
+ * `<pc-screen>` elements. The ScreenComponentElement interface also inherits the properties and
9
+ * methods of the {@link HTMLElement} interface.
8
10
  *
9
11
  * @category Components
10
12
  */
@@ -21,6 +23,7 @@ class ScreenComponentElement extends ComponentElement {
21
23
 
22
24
  private _scaleBlend = 0.5;
23
25
 
26
+ /** @ignore */
24
27
  constructor() {
25
28
  super('screen');
26
29
  }
@@ -4,10 +4,6 @@ import { ComponentElement } from './component';
4
4
  import { ScriptElement } from './script';
5
5
  import { AssetElement } from '../asset';
6
6
 
7
- const tmpV2 = new Vec2();
8
- const tmpV3 = new Vec3();
9
- const tmpV4 = new Vec4();
10
-
11
7
  // Add these interfaces at the top of the file, after the imports
12
8
  interface ScriptAttributesChangeEvent extends CustomEvent {
13
9
  detail: { attributes: any };
@@ -26,13 +22,16 @@ declare global {
26
22
  }
27
23
 
28
24
  /**
29
- * Represents a script component in the PlayCanvas engine.
25
+ * The ScriptComponentElement interface provides properties and methods for manipulating
26
+ * `<pc-scripts>` elements. The ScriptComponentElement interface also inherits the properties and
27
+ * methods of the {@link HTMLElement} interface.
30
28
  *
31
29
  * @category Components
32
30
  */
33
31
  class ScriptComponentElement extends ComponentElement {
34
32
  private observer: MutationObserver;
35
33
 
34
+ /** @ignore */
36
35
  constructor() {
37
36
  super('script');
38
37
 
@@ -73,23 +72,36 @@ class ScriptComponentElement extends ComponentElement {
73
72
  }
74
73
  }
75
74
 
76
- // Handle vectors
77
- if (Array.isArray(value)) {
78
- if (target[key] instanceof Vec2) {
79
- target[key] = tmpV2.set(value[0], value[1]);
75
+ // Handle arrays
76
+ if (value && typeof value === 'object' && Array.isArray(value)) {
77
+ // If it's an array of objects, recursively apply to each object
78
+ if (value.length > 0 && typeof value[0] === 'object') {
79
+ target[key] = value.map((item) => {
80
+ const obj = {};
81
+ for (const itemKey in item) {
82
+ applyValue(obj, itemKey, item[itemKey]);
83
+ }
84
+ return obj;
85
+ });
86
+ return;
87
+ }
88
+
89
+ // Handle vectors
90
+ if (value.length === 2 && typeof value[0] === 'number') {
91
+ target[key] = new Vec2(value[0], value[1]);
80
92
  return;
81
93
  }
82
- if (target[key] instanceof Vec3) {
83
- target[key] = tmpV3.set(value[0], value[1], value[2]);
94
+ if (value.length === 3 && typeof value[0] === 'number') {
95
+ target[key] = new Vec3(value[0], value[1], value[2]);
84
96
  return;
85
97
  }
86
- if (target[key] instanceof Vec4) {
87
- target[key] = tmpV4.set(value[0], value[1], value[2], value[3]);
98
+ if (value.length === 4 && typeof value[0] === 'number') {
99
+ target[key] = new Vec4(value[0], value[1], value[2], value[3]);
88
100
  return;
89
101
  }
90
102
  }
91
103
 
92
- // Handle nested objects
104
+ // Handle nested objects (non-array)
93
105
  if (value && typeof value === 'object' && !Array.isArray(value)) {
94
106
  if (!target[key] || typeof target[key] !== 'object') {
95
107
  target[key] = {};
@@ -1,5 +1,7 @@
1
1
  /**
2
- * Represents a script in the PlayCanvas engine.
2
+ * The ScriptElement interface provides properties and methods for manipulating
3
+ * `<pc-script>` elements. The ScriptElement interface also inherits the properties and
4
+ * methods of the {@link HTMLElement} interface.
3
5
  */
4
6
  class ScriptElement extends HTMLElement {
5
7
  private _attributes: string = '{}';
@@ -3,7 +3,9 @@ import { SoundComponent } from 'playcanvas';
3
3
  import { ComponentElement } from './component';
4
4
 
5
5
  /**
6
- * Represents a sound component in the PlayCanvas engine.
6
+ * The SoundComponentElement interface provides properties and methods for manipulating
7
+ * `<pc-sounds>` elements. The SoundComponentElement interface also inherits the properties and
8
+ * methods of the {@link HTMLElement} interface.
7
9
  *
8
10
  * @category Components
9
11
  */
@@ -22,6 +24,7 @@ class SoundComponentElement extends ComponentElement {
22
24
 
23
25
  private _volume: number = 1;
24
26
 
27
+ /** @ignore */
25
28
  constructor() {
26
29
  super('sound');
27
30
  }
@@ -5,7 +5,9 @@ import { AsyncElement } from '../async-element';
5
5
  import { SoundComponentElement } from './sound-component';
6
6
 
7
7
  /**
8
- * Represents a sound slot in the PlayCanvas engine.
8
+ * The SoundSlotElement interface provides properties and methods for manipulating
9
+ * `<pc-sound>` elements. The SoundSlotElement interface also inherits the properties and
10
+ * methods of the {@link AsyncElement} interface.
9
11
  */
10
12
  class SoundSlotElement extends AsyncElement {
11
13
  private _asset: string = '';
package/src/entity.ts CHANGED
@@ -1,10 +1,12 @@
1
- import { Entity, Vec3 } from 'playcanvas';
1
+ import { Application, Entity, Vec3 } from 'playcanvas';
2
2
 
3
3
  import { AsyncElement } from './async-element';
4
4
  import { parseVec3 } from './utils';
5
5
 
6
6
  /**
7
- * Represents an entity in the PlayCanvas engine.
7
+ * The EntityElement interface provides properties and methods for manipulating
8
+ * `<pc-entity>` elements. The EntityElement interface also inherits the properties and
9
+ * methods of the {@link HTMLElement} interface.
8
10
  */
9
11
  class EntityElement extends AsyncElement {
10
12
  /**
@@ -37,47 +39,104 @@ class EntityElement extends AsyncElement {
37
39
  */
38
40
  private _tags: string[] = [];
39
41
 
42
+ /**
43
+ * The pointer event listeners for the entity.
44
+ */
45
+ private _listeners: { [key: string]: EventListener[] } = {};
46
+
40
47
  /**
41
48
  * The PlayCanvas entity instance.
42
49
  */
43
50
  entity: Entity | null = null;
44
51
 
45
- async connectedCallback() {
46
- const closestApp = this.closestApp;
47
- if (!closestApp) return;
52
+ createEntity(app: Application) {
53
+ // Create a new entity
54
+ this.entity = new Entity(this.getAttribute('name') || this._name, app);
48
55
 
49
- // Wait for the app to complete initialization
50
- await closestApp.ready();
56
+ const enabled = this.getAttribute('enabled');
57
+ if (enabled) {
58
+ this.entity.enabled = enabled !== 'false';
59
+ }
51
60
 
52
- const app = closestApp.app!;
61
+ const position = this.getAttribute('position');
62
+ if (position) {
63
+ this.entity.setLocalPosition(parseVec3(position));
64
+ }
53
65
 
54
- // Create a new entity
55
- this.entity = new Entity(this._name, app);
56
-
57
- // Initialize from attributes
58
- const enabledAttr = this.getAttribute('enabled');
59
- const nameAttr = this.getAttribute('name');
60
- const positionAttr = this.getAttribute('position');
61
- const rotationAttr = this.getAttribute('rotation');
62
- const scaleAttr = this.getAttribute('scale');
63
- const tagsAttr = this.getAttribute('tags');
64
-
65
- if (enabledAttr) this.enabled = enabledAttr !== 'false';
66
- if (nameAttr) this.name = nameAttr;
67
- if (positionAttr) this.position = parseVec3(positionAttr);
68
- if (rotationAttr) this.rotation = parseVec3(rotationAttr);
69
- if (scaleAttr) this.scale = parseVec3(scaleAttr);
70
- if (tagsAttr) this.tags = tagsAttr.split(',').map(tag => tag.trim());
66
+ const rotation = this.getAttribute('rotation');
67
+ if (rotation) {
68
+ this.entity.setLocalEulerAngles(parseVec3(rotation));
69
+ }
70
+
71
+ const scale = this.getAttribute('scale');
72
+ if (scale) {
73
+ this.entity.setLocalScale(parseVec3(scale));
74
+ }
75
+
76
+ const tags = this.getAttribute('tags');
77
+ if (tags) {
78
+ this.entity.tags.add(tags.split(',').map(tag => tag.trim()));
79
+ }
80
+
81
+ // Handle pointer events
82
+ const pointerEvents = [
83
+ 'onpointerenter',
84
+ 'onpointerleave',
85
+ 'onpointerdown',
86
+ 'onpointerup',
87
+ 'onpointermove'
88
+ ];
89
+
90
+ pointerEvents.forEach((eventName) => {
91
+ const handler = this.getAttribute(eventName);
92
+ if (handler) {
93
+ const eventType = eventName.substring(2); // remove 'on' prefix
94
+ const eventHandler = (event: Event) => {
95
+ try {
96
+ /* eslint-disable-next-line no-new-func */
97
+ new Function('event', handler).call(this, event);
98
+ } catch (e) {
99
+ console.error('Error in event handler:', e);
100
+ }
101
+ };
102
+ this.addEventListener(eventType, eventHandler);
103
+ }
104
+ });
105
+ }
106
+
107
+ buildHierarchy(app: Application) {
108
+ if (!this.entity) return;
71
109
 
72
110
  const closestEntity = this.closestEntity;
73
- if (closestEntity) {
74
- closestEntity.ready().then(() => {
75
- closestEntity.entity!.addChild(this.entity!);
76
- this._onReady();
77
- });
111
+ if (closestEntity?.entity) {
112
+ closestEntity.entity.addChild(this.entity);
78
113
  } else {
79
114
  app.root.addChild(this.entity);
80
- this._onReady();
115
+ }
116
+
117
+ this._onReady();
118
+ }
119
+
120
+ connectedCallback() {
121
+ // Wait for app to be ready
122
+ const closestApp = this.closestApp;
123
+ if (!closestApp) return;
124
+
125
+ // If app is already running, create entity immediately
126
+ if (closestApp.hierarchyReady) {
127
+ const app = closestApp.app!;
128
+
129
+ this.createEntity(app);
130
+ this.buildHierarchy(app);
131
+
132
+ // Handle any child entities that might exist
133
+ const childEntities = this.querySelectorAll<EntityElement>('pc-entity');
134
+ childEntities.forEach((child) => {
135
+ child.createEntity(app);
136
+ });
137
+ childEntities.forEach((child) => {
138
+ child.buildHierarchy(app);
139
+ });
81
140
  }
82
141
  }
83
142
 
@@ -89,6 +148,7 @@ class EntityElement extends AsyncElement {
89
148
  (child as EntityElement).entity = null;
90
149
  });
91
150
 
151
+ // Destroy the entity
92
152
  this.entity.destroy();
93
153
  this.entity = null;
94
154
  }
@@ -210,7 +270,19 @@ class EntityElement extends AsyncElement {
210
270
  }
211
271
 
212
272
  static get observedAttributes() {
213
- return ['enabled', 'name', 'position', 'rotation', 'scale', 'tags'];
273
+ return [
274
+ 'enabled',
275
+ 'name',
276
+ 'position',
277
+ 'rotation',
278
+ 'scale',
279
+ 'tags',
280
+ 'onpointerenter',
281
+ 'onpointerleave',
282
+ 'onpointerdown',
283
+ 'onpointerup',
284
+ 'onpointermove'
285
+ ];
214
286
  }
215
287
 
216
288
  attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
@@ -233,8 +305,53 @@ class EntityElement extends AsyncElement {
233
305
  case 'tags':
234
306
  this.tags = newValue.split(',').map(tag => tag.trim());
235
307
  break;
308
+ case 'onpointerenter':
309
+ case 'onpointerleave':
310
+ case 'onpointerdown':
311
+ case 'onpointerup':
312
+ case 'onpointermove':
313
+ if (newValue) {
314
+ const eventName = name.substring(2);
315
+ // Use Function.prototype.bind to avoid new Function
316
+ const handler = (event: Event) => {
317
+ try {
318
+ const handlerStr = this.getAttribute(eventName) || '';
319
+ /* eslint-disable-next-line no-new-func */
320
+ new Function('event', handlerStr).call(this, event);
321
+ } catch (e) {
322
+ console.error('Error in event handler:', e);
323
+ }
324
+ };
325
+ this.addEventListener(eventName, handler);
326
+ }
327
+ break;
236
328
  }
237
329
  }
330
+
331
+ addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions) {
332
+ if (!this._listeners[type]) {
333
+ this._listeners[type] = [];
334
+ }
335
+ this._listeners[type].push(listener);
336
+ super.addEventListener(type, listener, options);
337
+ if (type.startsWith('pointer')) {
338
+ this.dispatchEvent(new CustomEvent(`${type}:connect`, { bubbles: true }));
339
+ }
340
+ }
341
+
342
+ removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions) {
343
+ if (this._listeners[type]) {
344
+ this._listeners[type] = this._listeners[type].filter(l => l !== listener);
345
+ }
346
+ super.removeEventListener(type, listener, options);
347
+ if (type.startsWith('pointer')) {
348
+ this.dispatchEvent(new CustomEvent(`${type}:disconnect`, { bubbles: true }));
349
+ }
350
+ }
351
+
352
+ hasListeners(type: string): boolean {
353
+ return Boolean(this._listeners[type]?.length);
354
+ }
238
355
  }
239
356
 
240
357
  customElements.define('pc-entity', EntityElement);
package/src/fog.ts ADDED
@@ -0,0 +1,121 @@
1
+ import { Color } from 'playcanvas';
2
+
3
+ import { parseColor } from './utils';
4
+
5
+ /**
6
+ * The FogElement interface provides properties and methods for manipulating
7
+ * `<pc-fog>` elements. The FogElement interface also inherits the properties and
8
+ * methods of the {@link HTMLElement} interface.
9
+ */
10
+ class FogElement extends HTMLElement {
11
+ private _color = new Color(0.5, 0.5, 0.5);
12
+
13
+ private _density = 0.001;
14
+
15
+ private _end = 100;
16
+
17
+ private _start = 0;
18
+
19
+ private _type: 'linear' | 'exp' | 'exp2' = 'linear';
20
+
21
+ private dispatchFogUpdate() {
22
+ const event = new CustomEvent('fogupdate', {
23
+ bubbles: true,
24
+ detail: {
25
+ color: this._color,
26
+ density: this._density,
27
+ end: this._end,
28
+ start: this._start,
29
+ type: this._type
30
+ }
31
+ });
32
+ this.dispatchEvent(event);
33
+ }
34
+
35
+ set color(value: Color) {
36
+ this._color = value;
37
+ this.dispatchFogUpdate();
38
+ }
39
+
40
+ get color(): Color {
41
+ return this._color;
42
+ }
43
+
44
+ set density(value: number) {
45
+ this._density = value;
46
+ this.dispatchFogUpdate();
47
+ }
48
+
49
+ get density(): number {
50
+ return this._density;
51
+ }
52
+
53
+ set end(value: number) {
54
+ this._end = value;
55
+ this.dispatchFogUpdate();
56
+ }
57
+
58
+ get end(): number {
59
+ return this._end;
60
+ }
61
+
62
+ set start(value: number) {
63
+ this._start = value;
64
+ this.dispatchFogUpdate();
65
+ }
66
+
67
+ get start(): number {
68
+ return this._start;
69
+ }
70
+
71
+ set type(value: 'linear' | 'exp' | 'exp2') {
72
+ this._type = value;
73
+ this.dispatchFogUpdate();
74
+ }
75
+
76
+ get type(): 'linear' | 'exp' | 'exp2' {
77
+ return this._type;
78
+ }
79
+
80
+ static get observedAttributes() {
81
+ return [
82
+ 'color',
83
+ 'density',
84
+ 'end',
85
+ 'start',
86
+ 'type'
87
+ ];
88
+ }
89
+
90
+ attributeChangedCallback(name: string, _oldValue: string, newValue: string) {
91
+ switch (name) {
92
+ case 'color':
93
+ this.color = parseColor(newValue);
94
+ break;
95
+ case 'density':
96
+ this.density = parseFloat(newValue);
97
+ break;
98
+ case 'end':
99
+ this.end = parseFloat(newValue);
100
+ break;
101
+ case 'start':
102
+ this.start = parseFloat(newValue);
103
+ break;
104
+ case 'type':
105
+ if (newValue === 'linear' || newValue === 'exp' || newValue === 'exp2') {
106
+ this.type = newValue;
107
+ }
108
+ break;
109
+ }
110
+ }
111
+
112
+ constructor() {
113
+ super();
114
+ // Dispatch initial fog state
115
+ this.dispatchFogUpdate();
116
+ }
117
+ }
118
+
119
+ customElements.define('pc-fog', FogElement);
120
+
121
+ export { FogElement };
package/src/material.ts CHANGED
@@ -4,7 +4,9 @@ import { AssetElement } from './asset';
4
4
  import { parseColor } from './utils';
5
5
 
6
6
  /**
7
- * Represents a material in the PlayCanvas engine.
7
+ * The MaterialElement interface provides properties and methods for manipulating
8
+ * `<pc-material>` elements. The MaterialElement interface also inherits the properties and
9
+ * methods of the {@link HTMLElement} interface.
8
10
  */
9
11
  class MaterialElement extends HTMLElement {
10
12
  private _diffuse = new Color(1, 1, 1);
@@ -21,8 +23,8 @@ class MaterialElement extends HTMLElement {
21
23
 
22
24
  createMaterial() {
23
25
  this.material = new StandardMaterial();
24
- this.material.glossInvert = true;
25
- this.material.useMetalness = true;
26
+ this.material.glossInvert = false;
27
+ this.material.useMetalness = false;
26
28
  this.material.diffuse = this._diffuse;
27
29
  this.diffuseMap = this._diffuseMap;
28
30
  this.metalnessMap = this._metalnessMap;
package/src/model.ts CHANGED
@@ -4,7 +4,9 @@ import { AssetElement } from './asset';
4
4
  import { AsyncElement } from './async-element';
5
5
 
6
6
  /**
7
- * Represents a model in the PlayCanvas engine.
7
+ * The ModelElement interface provides properties and methods for manipulating
8
+ * `<pc-model>` elements. The ModelElement interface also inherits the properties and
9
+ * methods of the {@link HTMLElement} interface.
8
10
  */
9
11
  class ModelElement extends AsyncElement {
10
12
  private _asset: string = '';
package/src/module.ts CHANGED
@@ -1,8 +1,14 @@
1
1
  import { basisInitialize, WasmModule } from 'playcanvas';
2
2
 
3
+ /**
4
+ * The ModuleElement interface provides properties and methods for manipulating
5
+ * `<pc-module>` elements. The ModuleElement interface also inherits the properties and
6
+ * methods of the {@link HTMLElement} interface.
7
+ */
3
8
  class ModuleElement extends HTMLElement {
4
9
  private loadPromise: Promise<void>;
5
10
 
11
+ /** @ignore */
6
12
  constructor() {
7
13
  super();
8
14
  this.loadPromise = this.loadModule();
package/src/scene.ts CHANGED
@@ -4,7 +4,9 @@ import { AsyncElement } from './async-element';
4
4
  import { parseColor } from './utils';
5
5
 
6
6
  /**
7
- * Represents a scene in the PlayCanvas engine.
7
+ * The SceneElement interface provides properties and methods for manipulating
8
+ * `<pc-scene>` elements. The SceneElement interface also inherits the properties and
9
+ * methods of the {@link HTMLElement} interface.
8
10
  */
9
11
  class SceneElement extends AsyncElement {
10
12
  /**
@@ -48,11 +50,11 @@ class SceneElement extends AsyncElement {
48
50
 
49
51
  updateSceneSettings() {
50
52
  if (this.scene) {
51
- this.scene.rendering.fog = this._fog;
52
- this.scene.rendering.fogColor = this._fogColor;
53
- this.scene.rendering.fogDensity = this._fogDensity;
54
- this.scene.rendering.fogStart = this._fogStart;
55
- this.scene.rendering.fogEnd = this._fogEnd;
53
+ this.scene.fog.type = this._fog;
54
+ this.scene.fog.color = this._fogColor;
55
+ this.scene.fog.density = this._fogDensity;
56
+ this.scene.fog.start = this._fogStart;
57
+ this.scene.fog.end = this._fogEnd;
56
58
  // ... set other properties on the scene as well
57
59
  }
58
60
  }
@@ -64,7 +66,7 @@ class SceneElement extends AsyncElement {
64
66
  set fog(value) {
65
67
  this._fog = value;
66
68
  if (this.scene) {
67
- this.scene.rendering.fog = value;
69
+ this.scene.fog.type = value;
68
70
  }
69
71
  }
70
72
 
@@ -83,7 +85,7 @@ class SceneElement extends AsyncElement {
83
85
  set fogColor(value: Color) {
84
86
  this._fogColor = value;
85
87
  if (this.scene) {
86
- this.scene.rendering.fogColor = value;
88
+ this.scene.fog.color = value;
87
89
  }
88
90
  }
89
91
 
@@ -102,7 +104,7 @@ class SceneElement extends AsyncElement {
102
104
  set fogDensity(value: number) {
103
105
  this._fogDensity = value;
104
106
  if (this.scene) {
105
- this.scene.rendering.fogDensity = value;
107
+ this.scene.fog.density = value;
106
108
  }
107
109
  }
108
110
 
@@ -121,7 +123,7 @@ class SceneElement extends AsyncElement {
121
123
  set fogStart(value: number) {
122
124
  this._fogStart = value;
123
125
  if (this.scene) {
124
- this.scene.rendering.fogStart = value;
126
+ this.scene.fog.start = value;
125
127
  }
126
128
  }
127
129
 
@@ -140,7 +142,7 @@ class SceneElement extends AsyncElement {
140
142
  set fogEnd(value: number) {
141
143
  this._fogEnd = value;
142
144
  if (this.scene) {
143
- this.scene.rendering.fogEnd = value;
145
+ this.scene.fog.end = value;
144
146
  }
145
147
  }
146
148