@playcanvas/web-components 0.1.7 → 0.1.9
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/app.d.ts +10 -1
- package/dist/asset.d.ts +3 -1
- package/dist/async-element.d.ts +2 -1
- package/dist/components/camera-component.d.ts +4 -4
- package/dist/components/collision-component.d.ts +4 -4
- package/dist/components/component.d.ts +3 -1
- package/dist/components/element-component.d.ts +4 -1
- package/dist/components/gsplat-component.d.ts +4 -1
- package/dist/components/light-component.d.ts +16 -4
- package/dist/components/listener-component.d.ts +4 -1
- package/dist/components/render-component.d.ts +4 -1
- package/dist/components/rigidbody-component.d.ts +4 -4
- package/dist/components/screen-component.d.ts +4 -1
- package/dist/components/script-component.d.ts +4 -1
- package/dist/components/script.d.ts +3 -1
- package/dist/components/sound-component.d.ts +4 -1
- package/dist/components/sound-slot.d.ts +3 -1
- package/dist/entity.d.ts +7 -3
- package/dist/material.d.ts +3 -1
- package/dist/model.d.ts +3 -1
- package/dist/module.d.ts +6 -0
- package/dist/pwc.cjs +195 -75
- package/dist/pwc.cjs.map +1 -1
- package/dist/pwc.js +195 -75
- 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 +196 -76
- package/dist/pwc.mjs.map +1 -1
- package/dist/scene.d.ts +3 -1
- package/dist/sky.d.ts +4 -2
- package/package.json +15 -13
- package/src/app.ts +28 -1
- package/src/asset.ts +3 -1
- package/src/async-element.ts +2 -1
- package/src/components/camera-component.ts +4 -4
- package/src/components/collision-component.ts +4 -4
- package/src/components/component.ts +3 -1
- package/src/components/element-component.ts +4 -2
- package/src/components/gsplat-component.ts +4 -1
- package/src/components/light-component.ts +30 -4
- package/src/components/listener-component.ts +4 -1
- package/src/components/render-component.ts +4 -1
- package/src/components/rigidbody-component.ts +4 -4
- package/src/components/screen-component.ts +4 -1
- package/src/components/script-component.ts +15 -1
- package/src/components/script.ts +3 -1
- package/src/components/sound-component.ts +4 -1
- package/src/components/sound-slot.ts +3 -1
- package/src/entity.ts +59 -27
- package/src/material.ts +3 -1
- package/src/model.ts +3 -1
- package/src/module.ts +6 -0
- package/src/scene.ts +13 -11
- package/src/sky.ts +5 -2
|
@@ -4,13 +4,16 @@ import { ComponentElement } from './component';
|
|
|
4
4
|
import { AssetElement } from '../asset';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* The GSplatComponentElement interface provides properties and methods for manipulating
|
|
8
|
+
* `<pc-splat>` elements. The GSplatComponentElement interface also inherits the properties and
|
|
9
|
+
* methods of the {@link HTMLElement} interface.
|
|
8
10
|
*
|
|
9
11
|
* @category Components
|
|
10
12
|
*/
|
|
11
13
|
class GSplatComponentElement extends ComponentElement {
|
|
12
14
|
private _asset: string = '';
|
|
13
15
|
|
|
16
|
+
/** @ignore */
|
|
14
17
|
constructor() {
|
|
15
18
|
super('gsplat');
|
|
16
19
|
}
|
|
@@ -4,7 +4,9 @@ import { ComponentElement } from './component';
|
|
|
4
4
|
import { parseColor } from '../utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* The LightComponentElement interface provides properties and methods for manipulating
|
|
8
|
+
* `<pc-light>` elements. The LightComponentElement interface also inherits the properties and
|
|
9
|
+
* methods of the {@link HTMLElement} interface.
|
|
8
10
|
*
|
|
9
11
|
* @category Components
|
|
10
12
|
*/
|
|
@@ -27,11 +29,11 @@ class LightComponentElement extends ComponentElement {
|
|
|
27
29
|
|
|
28
30
|
private _shadowDistance = 16;
|
|
29
31
|
|
|
32
|
+
private _shadowResolution = 1024;
|
|
33
|
+
|
|
30
34
|
private _type = 'directional';
|
|
31
35
|
|
|
32
|
-
/**
|
|
33
|
-
* Creates a new LightComponentElement.
|
|
34
|
-
*/
|
|
36
|
+
/** @ignore */
|
|
35
37
|
constructor() {
|
|
36
38
|
super('light');
|
|
37
39
|
}
|
|
@@ -47,6 +49,7 @@ class LightComponentElement extends ComponentElement {
|
|
|
47
49
|
range: this._range,
|
|
48
50
|
shadowBias: this._shadowBias,
|
|
49
51
|
shadowDistance: this._shadowDistance,
|
|
52
|
+
shadowResolution: this._shadowResolution,
|
|
50
53
|
type: this._type
|
|
51
54
|
};
|
|
52
55
|
}
|
|
@@ -230,6 +233,25 @@ class LightComponentElement extends ComponentElement {
|
|
|
230
233
|
return this._shadowDistance;
|
|
231
234
|
}
|
|
232
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Sets the shadow resolution of the light.
|
|
238
|
+
* @param value - The shadow resolution.
|
|
239
|
+
*/
|
|
240
|
+
set shadowResolution(value: number) {
|
|
241
|
+
this._shadowResolution = value;
|
|
242
|
+
if (this.component) {
|
|
243
|
+
this.component.shadowResolution = value;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Gets the shadow resolution of the light.
|
|
249
|
+
* @returns The shadow resolution.
|
|
250
|
+
*/
|
|
251
|
+
get shadowResolution() {
|
|
252
|
+
return this._shadowResolution;
|
|
253
|
+
}
|
|
254
|
+
|
|
233
255
|
/**
|
|
234
256
|
* Sets the type of the light.
|
|
235
257
|
* @param value - The type.
|
|
@@ -266,6 +288,7 @@ class LightComponentElement extends ComponentElement {
|
|
|
266
288
|
'range',
|
|
267
289
|
'shadow-bias',
|
|
268
290
|
'shadow-distance',
|
|
291
|
+
'shadow-resolution',
|
|
269
292
|
'type'
|
|
270
293
|
];
|
|
271
294
|
}
|
|
@@ -301,6 +324,9 @@ class LightComponentElement extends ComponentElement {
|
|
|
301
324
|
case 'shadow-distance':
|
|
302
325
|
this.shadowDistance = Number(newValue);
|
|
303
326
|
break;
|
|
327
|
+
case 'shadow-resolution':
|
|
328
|
+
this.shadowResolution = Number(newValue);
|
|
329
|
+
break;
|
|
304
330
|
case 'type':
|
|
305
331
|
this.type = newValue;
|
|
306
332
|
break;
|
|
@@ -3,11 +3,14 @@ import { AudioListenerComponent } from 'playcanvas';
|
|
|
3
3
|
import { ComponentElement } from './component';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
}
|
|
@@ -2,6 +2,7 @@ import { ScriptComponent, Script, Vec2, Vec3, Vec4 } from 'playcanvas';
|
|
|
2
2
|
|
|
3
3
|
import { ComponentElement } from './component';
|
|
4
4
|
import { ScriptElement } from './script';
|
|
5
|
+
import { AssetElement } from '../asset';
|
|
5
6
|
|
|
6
7
|
const tmpV2 = new Vec2();
|
|
7
8
|
const tmpV3 = new Vec3();
|
|
@@ -25,13 +26,16 @@ declare global {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
+
* The ScriptComponentElement interface provides properties and methods for manipulating
|
|
30
|
+
* `<pc-scripts>` elements. The ScriptComponentElement interface also inherits the properties and
|
|
31
|
+
* methods of the {@link HTMLElement} interface.
|
|
29
32
|
*
|
|
30
33
|
* @category Components
|
|
31
34
|
*/
|
|
32
35
|
class ScriptComponentElement extends ComponentElement {
|
|
33
36
|
private observer: MutationObserver;
|
|
34
37
|
|
|
38
|
+
/** @ignore */
|
|
35
39
|
constructor() {
|
|
36
40
|
super('script');
|
|
37
41
|
|
|
@@ -62,6 +66,16 @@ class ScriptComponentElement extends ComponentElement {
|
|
|
62
66
|
const attributesObject = attributes ? JSON.parse(attributes) : {};
|
|
63
67
|
|
|
64
68
|
const applyValue = (target: any, key: string, value: any) => {
|
|
69
|
+
// Handle asset references
|
|
70
|
+
if (typeof value === 'string' && value.startsWith('asset:')) {
|
|
71
|
+
const assetId = value.slice(6);
|
|
72
|
+
const assetElement = document.querySelector(`pc-asset#${assetId}`) as AssetElement;
|
|
73
|
+
if (assetElement) {
|
|
74
|
+
target[key] = assetElement.asset;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
65
79
|
// Handle vectors
|
|
66
80
|
if (Array.isArray(value)) {
|
|
67
81
|
if (target[key] instanceof Vec2) {
|
package/src/components/script.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
/**
|
|
@@ -42,40 +44,69 @@ class EntityElement extends AsyncElement {
|
|
|
42
44
|
*/
|
|
43
45
|
entity: Entity | null = null;
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
createEntity(app: Application) {
|
|
48
|
+
// Create a new entity
|
|
49
|
+
this.entity = new Entity(this.getAttribute('name') || this._name, app);
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
const enabled = this.getAttribute('enabled');
|
|
52
|
+
if (enabled) {
|
|
53
|
+
this.entity.enabled = enabled !== 'false';
|
|
54
|
+
}
|
|
51
55
|
|
|
52
|
-
const
|
|
56
|
+
const position = this.getAttribute('position');
|
|
57
|
+
if (position) {
|
|
58
|
+
this.entity.setLocalPosition(parseVec3(position));
|
|
59
|
+
}
|
|
53
60
|
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
const rotation = this.getAttribute('rotation');
|
|
62
|
+
if (rotation) {
|
|
63
|
+
this.entity.setLocalEulerAngles(parseVec3(rotation));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const scale = this.getAttribute('scale');
|
|
67
|
+
if (scale) {
|
|
68
|
+
this.entity.setLocalScale(parseVec3(scale));
|
|
69
|
+
}
|
|
56
70
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const tagsAttr = this.getAttribute('tags');
|
|
71
|
+
const tags = this.getAttribute('tags');
|
|
72
|
+
if (tags) {
|
|
73
|
+
this.entity.tags.add(tags.split(',').map(tag => tag.trim()));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
63
76
|
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
if (rotationAttr) this.rotation = parseVec3(rotationAttr);
|
|
67
|
-
if (scaleAttr) this.scale = parseVec3(scaleAttr);
|
|
68
|
-
if (tagsAttr) this.tags = tagsAttr.split(',').map(tag => tag.trim());
|
|
77
|
+
buildHierarchy(app: Application) {
|
|
78
|
+
if (!this.entity) return;
|
|
69
79
|
|
|
70
80
|
const closestEntity = this.closestEntity;
|
|
71
|
-
if (closestEntity) {
|
|
72
|
-
closestEntity.
|
|
73
|
-
closestEntity.entity!.addChild(this.entity!);
|
|
74
|
-
this._onReady();
|
|
75
|
-
});
|
|
81
|
+
if (closestEntity?.entity) {
|
|
82
|
+
closestEntity.entity.addChild(this.entity);
|
|
76
83
|
} else {
|
|
77
84
|
app.root.addChild(this.entity);
|
|
78
|
-
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
this._onReady();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
connectedCallback() {
|
|
91
|
+
// Wait for app to be ready
|
|
92
|
+
const closestApp = this.closestApp;
|
|
93
|
+
if (!closestApp) return;
|
|
94
|
+
|
|
95
|
+
// If app is already running, create entity immediately
|
|
96
|
+
if (closestApp.hierarchyReady) {
|
|
97
|
+
const app = closestApp.app!;
|
|
98
|
+
|
|
99
|
+
this.createEntity(app);
|
|
100
|
+
this.buildHierarchy(app);
|
|
101
|
+
|
|
102
|
+
// Handle any child entities that might exist
|
|
103
|
+
const childEntities = this.querySelectorAll<EntityElement>('pc-entity');
|
|
104
|
+
childEntities.forEach((child) => {
|
|
105
|
+
child.createEntity(app);
|
|
106
|
+
});
|
|
107
|
+
childEntities.forEach((child) => {
|
|
108
|
+
child.buildHierarchy(app);
|
|
109
|
+
});
|
|
79
110
|
}
|
|
80
111
|
}
|
|
81
112
|
|
|
@@ -87,6 +118,7 @@ class EntityElement extends AsyncElement {
|
|
|
87
118
|
(child as EntityElement).entity = null;
|
|
88
119
|
});
|
|
89
120
|
|
|
121
|
+
// Destroy the entity
|
|
90
122
|
this.entity.destroy();
|
|
91
123
|
this.entity = null;
|
|
92
124
|
}
|
package/src/material.ts
CHANGED
|
@@ -4,7 +4,9 @@ import { AssetElement } from './asset';
|
|
|
4
4
|
import { parseColor } from './utils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
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);
|
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
|
-
*
|
|
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
|
-
*
|
|
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.
|
|
52
|
-
this.scene.
|
|
53
|
-
this.scene.
|
|
54
|
-
this.scene.
|
|
55
|
-
this.scene.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
145
|
+
this.scene.fog.end = value;
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
148
|
|
package/src/sky.ts
CHANGED
|
@@ -5,7 +5,9 @@ import { AsyncElement } from './async-element';
|
|
|
5
5
|
import { parseVec3 } from './utils';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* The SkyElement interface provides properties and methods for manipulating
|
|
9
|
+
* `<pc-sky>` elements. The SkyElement interface also inherits the properties and
|
|
10
|
+
* methods of the {@link HTMLElement} interface.
|
|
9
11
|
*/
|
|
10
12
|
class SkyElement extends AsyncElement {
|
|
11
13
|
private _asset = '';
|
|
@@ -39,9 +41,9 @@ class SkyElement extends AsyncElement {
|
|
|
39
41
|
if (!this._scene) return;
|
|
40
42
|
|
|
41
43
|
const source = asset.resource as Texture;
|
|
42
|
-
source.anisotropy = 4;
|
|
43
44
|
|
|
44
45
|
const skybox = EnvLighting.generateSkyboxCubemap(source);
|
|
46
|
+
skybox.anisotropy = 4;
|
|
45
47
|
this._scene.skybox = skybox;
|
|
46
48
|
|
|
47
49
|
if (this._lighting) {
|
|
@@ -58,6 +60,7 @@ class SkyElement extends AsyncElement {
|
|
|
58
60
|
this._scene.sky.type = this._type;
|
|
59
61
|
this._scene.sky.node.setLocalScale(this._scale);
|
|
60
62
|
this._scene.sky.center = this._center;
|
|
63
|
+
this._scene.skyboxIntensity = this._intensity;
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
private async _loadSkybox() {
|