@playcanvas/web-components 0.3.0 → 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.
- package/LICENSE +21 -21
- package/README.md +84 -84
- package/dist/components/light-component.d.ts +48 -0
- package/dist/components/splat-component.d.ts +0 -13
- package/dist/pwc.cjs +275 -207
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +275 -207
- package/dist/pwc.js.map +1 -1
- package/dist/pwc.min.js +1 -1
- package/dist/pwc.min.js.map +1 -1
- package/dist/pwc.mjs +276 -208
- package/dist/pwc.mjs.map +1 -1
- package/package.json +76 -66
- package/src/app.ts +612 -606
- package/src/asset.ts +159 -159
- package/src/async-element.ts +46 -46
- package/src/colors.ts +150 -150
- package/src/components/camera-component.ts +557 -557
- package/src/components/collision-component.ts +183 -183
- package/src/components/component.ts +97 -97
- package/src/components/element-component.ts +367 -367
- package/src/components/light-component.ts +570 -466
- package/src/components/listener-component.ts +30 -30
- package/src/components/particlesystem-component.ts +155 -155
- package/src/components/render-component.ts +147 -147
- package/src/components/rigidbody-component.ts +227 -227
- package/src/components/screen-component.ts +157 -157
- package/src/components/script-component.ts +270 -270
- package/src/components/script.ts +90 -90
- package/src/components/sound-component.ts +230 -230
- package/src/components/sound-slot.ts +288 -288
- package/src/components/splat-component.ts +102 -133
- package/src/entity.ts +360 -360
- package/src/index.ts +63 -63
- package/src/material.ts +141 -141
- package/src/model.ts +111 -111
- package/src/module.ts +43 -43
- package/src/scene.ts +217 -217
- package/src/sky.ts +293 -293
- 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
|
+
};
|