@playcanvas/web-components 0.8.2 → 0.10.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/README.md +18 -0
- package/dist/app.d.ts +13 -4
- package/dist/asset.d.ts +33 -3
- package/dist/async-element.d.ts +54 -4
- package/dist/components/button-component.d.ts +11 -5
- package/dist/components/camera-component.d.ts +10 -5
- package/dist/components/collision-component.d.ts +10 -5
- package/dist/components/component.d.ts +8 -2
- package/dist/components/element-component.d.ts +18 -13
- package/dist/components/gsplat-component.d.ts +7 -2
- package/dist/components/layoutchild-component.d.ts +7 -2
- package/dist/components/layoutgroup-component.d.ts +22 -16
- package/dist/components/light-component.d.ts +13 -7
- package/dist/components/listener-component.d.ts +6 -1
- package/dist/components/particlesystem-component.d.ts +7 -2
- package/dist/components/render-component.d.ts +14 -5
- package/dist/components/rigidbody-component.d.ts +10 -5
- package/dist/components/screen-component.d.ts +7 -2
- package/dist/components/script-component.d.ts +116 -16
- package/dist/components/script.d.ts +79 -8
- package/dist/components/scrollbar-component.d.ts +11 -5
- package/dist/components/scrollview-component.d.ts +18 -11
- package/dist/components/sound-component.d.ts +7 -2
- package/dist/components/sound-slot.d.ts +17 -4
- package/dist/custom-elements.json +16231 -0
- package/dist/entity.d.ts +45 -3
- package/dist/index.d.ts +3 -2
- package/dist/material.d.ts +976 -4
- package/dist/model.d.ts +6 -1
- package/dist/module.d.ts +15 -0
- package/dist/parse.d.ts +144 -0
- package/dist/pwc.cjs +5735 -2923
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +5735 -2923
- 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.min.mjs +2 -0
- package/dist/pwc.min.mjs.map +1 -0
- package/dist/pwc.mjs +5736 -2925
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.ts +15 -6
- package/dist/sky.d.ts +7 -1
- package/dist/vscode.html-custom-data.json +1795 -0
- package/dist/web-types.json +3592 -0
- package/package.json +32 -14
- package/src/app.ts +42 -15
- package/src/asset.ts +78 -8
- package/src/async-element.ts +89 -5
- package/src/components/button-component.ts +31 -24
- package/src/components/camera-component.ts +30 -24
- package/src/components/collision-component.ts +20 -14
- package/src/components/component.ts +33 -14
- package/src/components/element-component.ts +62 -56
- package/src/components/gsplat-component.ts +16 -9
- package/src/components/layoutchild-component.ts +17 -10
- package/src/components/layoutgroup-component.ts +39 -32
- package/src/components/light-component.ts +34 -32
- package/src/components/listener-component.ts +8 -2
- package/src/components/particlesystem-component.ts +10 -4
- package/src/components/render-component.ts +28 -12
- package/src/components/rigidbody-component.ts +22 -16
- package/src/components/screen-component.ts +16 -10
- package/src/components/script-component.ts +512 -125
- package/src/components/script.ts +123 -16
- package/src/components/scrollbar-component.ts +21 -14
- package/src/components/scrollview-component.ts +42 -34
- package/src/components/sound-component.ts +17 -10
- package/src/components/sound-slot.ts +50 -19
- package/src/entity.ts +84 -76
- package/src/index.ts +5 -2
- package/src/material.ts +2432 -62
- package/src/model.ts +8 -2
- package/src/module.ts +16 -0
- package/src/parse.ts +298 -0
- package/src/scene.ts +26 -13
- package/src/sky.ts +36 -18
- package/dist/utils.d.ts +0 -56
- package/src/utils.ts +0 -119
package/src/utils.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { Color, Entity, 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
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Resolves an enum value supplied as either a named string (looked up in `map`) or a numeric
|
|
75
|
-
* string. Falls back to `defaultValue` when the value is neither a known name nor a finite number.
|
|
76
|
-
*
|
|
77
|
-
* @param value - The attribute value to parse.
|
|
78
|
-
* @param map - A map of named values to their numeric enum equivalents.
|
|
79
|
-
* @param defaultValue - The value to return when parsing fails.
|
|
80
|
-
* @returns The resolved numeric enum value.
|
|
81
|
-
*/
|
|
82
|
-
export const parseEnum = (value: string, map: Map<string, number>, defaultValue: number): number => {
|
|
83
|
-
const named = map.get(value);
|
|
84
|
-
if (named !== undefined) {
|
|
85
|
-
return named;
|
|
86
|
-
}
|
|
87
|
-
const numeric = Number(value);
|
|
88
|
-
return Number.isFinite(numeric) ? numeric : defaultValue;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Resolves a reference string to the {@link Entity} backing a `<pc-entity>` element. The reference
|
|
93
|
-
* can be a CSS selector (e.g. `#my-id`, `pc-entity[name="Foo"]`), a bare element id, or a bare
|
|
94
|
-
* entity name. Returns `null` if no matching element (or backing entity) is found.
|
|
95
|
-
*
|
|
96
|
-
* @param ref - The reference string to resolve.
|
|
97
|
-
* @returns The resolved entity, or `null`.
|
|
98
|
-
*/
|
|
99
|
-
export const getEntity = (ref: string): Entity | null => {
|
|
100
|
-
if (!ref) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
let element: Element | null = null;
|
|
105
|
-
|
|
106
|
-
// Try the reference as a CSS selector. An invalid selector (e.g. a bare name containing
|
|
107
|
-
// spaces) throws, in which case we fall back to id/name lookups below.
|
|
108
|
-
try {
|
|
109
|
-
element = document.querySelector(ref);
|
|
110
|
-
} catch {
|
|
111
|
-
element = null;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (!element) {
|
|
115
|
-
element = document.getElementById(ref) ?? document.querySelector(`pc-entity[name="${ref}"]`);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return (element as { entity?: Entity } | null)?.entity ?? null;
|
|
119
|
-
};
|