@playcanvas/web-components 0.2.12 → 0.5.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.
Files changed (41) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +84 -84
  3. package/dist/components/element-component.d.ts +12 -0
  4. package/dist/components/light-component.d.ts +48 -0
  5. package/dist/components/splat-component.d.ts +0 -13
  6. package/dist/pwc.cjs +298 -207
  7. package/dist/pwc.cjs.map +1 -1
  8. package/dist/pwc.js +298 -207
  9. package/dist/pwc.js.map +1 -1
  10. package/dist/pwc.min.js +1 -1
  11. package/dist/pwc.min.js.map +1 -1
  12. package/dist/pwc.mjs +299 -208
  13. package/dist/pwc.mjs.map +1 -1
  14. package/package.json +76 -64
  15. package/src/app.ts +612 -606
  16. package/src/asset.ts +159 -159
  17. package/src/async-element.ts +46 -46
  18. package/src/colors.ts +150 -150
  19. package/src/components/camera-component.ts +557 -557
  20. package/src/components/collision-component.ts +183 -183
  21. package/src/components/component.ts +97 -97
  22. package/src/components/element-component.ts +367 -341
  23. package/src/components/light-component.ts +570 -466
  24. package/src/components/listener-component.ts +30 -30
  25. package/src/components/particlesystem-component.ts +155 -155
  26. package/src/components/render-component.ts +147 -147
  27. package/src/components/rigidbody-component.ts +227 -227
  28. package/src/components/screen-component.ts +157 -157
  29. package/src/components/script-component.ts +270 -270
  30. package/src/components/script.ts +90 -90
  31. package/src/components/sound-component.ts +230 -230
  32. package/src/components/sound-slot.ts +288 -288
  33. package/src/components/splat-component.ts +102 -133
  34. package/src/entity.ts +360 -360
  35. package/src/index.ts +63 -63
  36. package/src/material.ts +141 -141
  37. package/src/model.ts +111 -111
  38. package/src/module.ts +43 -43
  39. package/src/scene.ts +217 -217
  40. package/src/sky.ts +293 -293
  41. package/src/utils.ts +71 -71
package/src/utils.ts CHANGED
@@ -1,71 +1,71 @@
1
- import { Color, Quat, Vec2, Vec3, Vec4 } from 'playcanvas';
2
-
3
- import { CSS_COLORS } from './colors';
4
-
5
- /**
6
- * Parse a color string into a Color object. String can be in the format of '#rgb', '#rgba',
7
- * '#rrggbb', '#rrggbbaa', or a string of 3 or 4 comma-delimited numbers.
8
- *
9
- * @param value - The color string to parse.
10
- * @returns The parsed Color object.
11
- */
12
- export const parseColor = (value: string): Color => {
13
- // Check if it's a CSS color name first
14
- const hexColor = CSS_COLORS[value.toLowerCase()];
15
- if (hexColor) {
16
- return new Color().fromString(hexColor);
17
- }
18
-
19
- if (value.startsWith('#')) {
20
- return new Color().fromString(value);
21
- }
22
-
23
- const components = value.split(' ').map(Number);
24
- return new Color(components);
25
- };
26
-
27
- /**
28
- * Parse an Euler angles string into a Quat object. String can be in the format of 'x,y,z'.
29
- *
30
- * @param value - The Euler angles string to parse.
31
- * @returns The parsed Quat object.
32
- */
33
- export const parseQuat = (value: string): Quat => {
34
- const [x, y, z] = value.split(' ').map(Number);
35
- const q = new Quat();
36
- q.setFromEulerAngles(x, y, z);
37
- return q;
38
- };
39
-
40
- /**
41
- * Parse a Vec2 string into a Vec2 object. String can be in the format of 'x,y'.
42
- *
43
- * @param value - The Vec2 string to parse.
44
- * @returns The parsed Vec2 object.
45
- */
46
- export const parseVec2 = (value: string): Vec2 => {
47
- const components = value.split(' ').map(Number);
48
- return new Vec2(components);
49
- };
50
-
51
- /**
52
- * Parse a Vec3 string into a Vec3 object. String can be in the format of 'x,y,z'.
53
- *
54
- * @param value - The Vec3 string to parse.
55
- * @returns The parsed Vec3 object.
56
- */
57
- export const parseVec3 = (value: string): Vec3 => {
58
- const components = value.split(' ').map(Number);
59
- return new Vec3(components);
60
- };
61
-
62
- /**
63
- * Parse a Vec4 string into a Vec4 object. String can be in the format of 'x,y,z,w'.
64
- *
65
- * @param value - The Vec4 string to parse.
66
- * @returns The parsed Vec4 object.
67
- */
68
- export const parseVec4 = (value: string): Vec4 => {
69
- const components = value.split(' ').map(Number);
70
- return new Vec4(components);
71
- };
1
+ import { Color, Quat, Vec2, Vec3, Vec4 } from 'playcanvas';
2
+
3
+ import { CSS_COLORS } from './colors';
4
+
5
+ /**
6
+ * Parse a color string into a Color object. String can be in the format of '#rgb', '#rgba',
7
+ * '#rrggbb', '#rrggbbaa', or a string of 3 or 4 comma-delimited numbers.
8
+ *
9
+ * @param value - The color string to parse.
10
+ * @returns The parsed Color object.
11
+ */
12
+ export const parseColor = (value: string): Color => {
13
+ // Check if it's a CSS color name first
14
+ const hexColor = CSS_COLORS[value.toLowerCase()];
15
+ if (hexColor) {
16
+ return new Color().fromString(hexColor);
17
+ }
18
+
19
+ if (value.startsWith('#')) {
20
+ return new Color().fromString(value);
21
+ }
22
+
23
+ const components = value.split(' ').map(Number);
24
+ return new Color(components);
25
+ };
26
+
27
+ /**
28
+ * Parse an Euler angles string into a Quat object. String can be in the format of 'x,y,z'.
29
+ *
30
+ * @param value - The Euler angles string to parse.
31
+ * @returns The parsed Quat object.
32
+ */
33
+ export const parseQuat = (value: string): Quat => {
34
+ const [x, y, z] = value.split(' ').map(Number);
35
+ const q = new Quat();
36
+ q.setFromEulerAngles(x, y, z);
37
+ return q;
38
+ };
39
+
40
+ /**
41
+ * Parse a Vec2 string into a Vec2 object. String can be in the format of 'x,y'.
42
+ *
43
+ * @param value - The Vec2 string to parse.
44
+ * @returns The parsed Vec2 object.
45
+ */
46
+ export const parseVec2 = (value: string): Vec2 => {
47
+ const components = value.split(' ').map(Number);
48
+ return new Vec2(components);
49
+ };
50
+
51
+ /**
52
+ * Parse a Vec3 string into a Vec3 object. String can be in the format of 'x,y,z'.
53
+ *
54
+ * @param value - The Vec3 string to parse.
55
+ * @returns The parsed Vec3 object.
56
+ */
57
+ export const parseVec3 = (value: string): Vec3 => {
58
+ const components = value.split(' ').map(Number);
59
+ return new Vec3(components);
60
+ };
61
+
62
+ /**
63
+ * Parse a Vec4 string into a Vec4 object. String can be in the format of 'x,y,z,w'.
64
+ *
65
+ * @param value - The Vec4 string to parse.
66
+ * @returns The parsed Vec4 object.
67
+ */
68
+ export const parseVec4 = (value: string): Vec4 => {
69
+ const components = value.split(' ').map(Number);
70
+ return new Vec4(components);
71
+ };