@zephyr3d/editor 0.3.8 → 0.3.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/assets/{index-BZ1L8ggE.js → index-CO6yA4Rj.js} +313 -11
- package/dist/assistant/zephyr-types-index.json +13834 -11679
- package/dist/index.html +1 -1
- package/dist/modules/zephyr3d_backend-webgpu.js +1 -1
- package/dist/modules/zephyr3d_backend-webgpu.js.map +1 -1
- package/dist/modules/zephyr3d_device.js +2 -2
- package/dist/modules/zephyr3d_device.js.map +1 -1
- package/dist/modules/zephyr3d_scene.js +2325 -515
- package/dist/modules/zephyr3d_scene.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/device/dist/device.js +2 -2
- package/dist/vendor/zephyr3d/device/dist/device.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/app/engine.js +3 -1
- package/dist/vendor/zephyr3d/scene/dist/app/engine.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/asset/assetmanager.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/asset/assetmanager.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js +87 -0
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/index.d.ts +158 -4
- package/dist/vendor/zephyr3d/scene/dist/index.js +3 -0
- package/dist/vendor/zephyr3d/scene/dist/index.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/meshmaterial.js +8 -1
- package/dist/vendor/zephyr3d/scene/dist/material/meshmaterial.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/shader/helper.js +6 -0
- package/dist/vendor/zephyr3d/scene/dist/material/shader/helper.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/skin.js +263 -0
- package/dist/vendor/zephyr3d/scene/dist/material/skin.js.map +1 -0
- package/dist/vendor/zephyr3d/scene/dist/posteffect/compositor.js +3 -0
- package/dist/vendor/zephyr3d/scene/dist/posteffect/compositor.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/posteffect/skinsss.js +194 -0
- package/dist/vendor/zephyr3d/scene/dist/posteffect/skinsss.js.map +1 -0
- package/dist/vendor/zephyr3d/scene/dist/posteffect/ssr.js +26 -49
- package/dist/vendor/zephyr3d/scene/dist/posteffect/ssr.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/posteffect/sss.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/posteffect/sss.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/posteffect/taa.js +2 -40
- package/dist/vendor/zephyr3d/scene/dist/posteffect/taa.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/abuffer_oit.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/abuffer_oit.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/drawable_mixin.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/drawable_mixin.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/fbm_wavegenerator.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/gerstner_wavegenerator.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/globalbindgroup_allocator.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/lightpass.js +4 -1
- package/dist/vendor/zephyr3d/scene/dist/render/lightpass.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/render_queue.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/render_queue.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/renderer.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/render/renderer.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/device_pool_allocator.js +12 -5
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/forward_plus_builder.js +78 -8
- package/dist/vendor/zephyr3d/scene/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/basesprite.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/basesprite.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/batchgroup.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/batchgroup.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/environment.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/environment.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/light.js +158 -154
- package/dist/vendor/zephyr3d/scene/dist/scene/light.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/mesh.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/mesh.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/msdftext.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/msdftext.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/msdftextsprite.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/particlesys.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/particlesys.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/scene.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/scene.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/terrain-cm/grass.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/terrain-cm/grassmaterial.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/terrain-cm/terrain-cm.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/scene/water.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/scene/water.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shaders/shadow.js +617 -1
- package/dist/vendor/zephyr3d/scene/dist/shaders/shadow.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/esm.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/esm.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/pcf_opt.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/pcf_pd.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/pcss.js +182 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/pcss.js.map +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/shader.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/shader.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/shadowmapper.js +183 -105
- package/dist/vendor/zephyr3d/scene/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/ssm.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/ssm.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/vsm.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/shadow/vsm.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js +3 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/animation.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/batch.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js +122 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/common.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/light.js +102 -21
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/material.js +195 -3
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/mesh.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/node.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/particle.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/primitive.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/sprite.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/terrain.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/text.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/water.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/values.js +1 -0
- package/dist/vendor/zephyr3d/scene/dist/values.js.map +1 -1
- package/electron/main.cjs +30 -6
- package/package.json +4 -4
|
@@ -4,9 +4,9 @@ import { BoundingBox } from '../utility/bounding_volume.js';
|
|
|
4
4
|
import { ShadowMapper } from '../shadow/shadowmapper.js';
|
|
5
5
|
import { LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT, LIGHT_TYPE_RECT } from '../values.js';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Base class for any kind of light node
|
|
9
|
-
* @public
|
|
7
|
+
/**
|
|
8
|
+
* Base class for any kind of light node
|
|
9
|
+
* @public
|
|
10
10
|
*/ class BaseLight extends GraphNode {
|
|
11
11
|
/** @internal */ _type;
|
|
12
12
|
/** @internal */ _intensity;
|
|
@@ -14,10 +14,10 @@ import { LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT, LIGHT_TYPE_R
|
|
|
14
14
|
/** @internal */ _directionCutoff;
|
|
15
15
|
/** @internal */ _diffuseIntensity;
|
|
16
16
|
/** @internal */ _extraParams;
|
|
17
|
-
/**
|
|
18
|
-
* Creates a light node
|
|
19
|
-
* @param scene - The scene to which the light node belongs
|
|
20
|
-
* @param type - Type of the light node
|
|
17
|
+
/**
|
|
18
|
+
* Creates a light node
|
|
19
|
+
* @param scene - The scene to which the light node belongs
|
|
20
|
+
* @param type - Type of the light node
|
|
21
21
|
*/ constructor(scene, type){
|
|
22
22
|
super(scene);
|
|
23
23
|
this._intensity = 1;
|
|
@@ -36,66 +36,66 @@ import { LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT, LIGHT_TYPE_R
|
|
|
36
36
|
set intensity(val) {
|
|
37
37
|
this.setIntensity(val);
|
|
38
38
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Position and range of the light
|
|
41
|
-
*
|
|
42
|
-
* @remarks
|
|
43
|
-
* Gets the position in world space of the light.
|
|
44
|
-
* Light range is encoded into the W component.
|
|
39
|
+
/**
|
|
40
|
+
* Position and range of the light
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* Gets the position in world space of the light.
|
|
44
|
+
* Light range is encoded into the W component.
|
|
45
45
|
*/ get positionAndRange() {
|
|
46
46
|
if (!this._positionRange) {
|
|
47
47
|
this.computeUniforms();
|
|
48
48
|
}
|
|
49
49
|
return this._positionRange;
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Direction and cutoff of the light
|
|
53
|
-
*
|
|
54
|
-
* @remarks
|
|
55
|
-
* Gets the direction in world space of the light
|
|
56
|
-
* Light cutoff (for spot light only) is encoded into the W component.
|
|
51
|
+
/**
|
|
52
|
+
* Direction and cutoff of the light
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* Gets the direction in world space of the light
|
|
56
|
+
* Light cutoff (for spot light only) is encoded into the W component.
|
|
57
57
|
*/ get directionAndCutoff() {
|
|
58
58
|
if (!this._directionCutoff) {
|
|
59
59
|
this.computeUniforms();
|
|
60
60
|
}
|
|
61
61
|
return this._directionCutoff;
|
|
62
62
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Color and intensity of the light
|
|
65
|
-
*
|
|
66
|
-
* @remarks
|
|
67
|
-
* Gets the color of the light.
|
|
68
|
-
* Light intensity is encoded into the W component.
|
|
63
|
+
/**
|
|
64
|
+
* Color and intensity of the light
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* Gets the color of the light.
|
|
68
|
+
* Light intensity is encoded into the W component.
|
|
69
69
|
*/ get diffuseAndIntensity() {
|
|
70
70
|
if (!this._diffuseIntensity) {
|
|
71
71
|
this.computeUniforms();
|
|
72
72
|
}
|
|
73
73
|
return this._diffuseIntensity;
|
|
74
74
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Extra parameters of the light
|
|
77
|
-
*
|
|
78
|
-
* @remarks
|
|
79
|
-
* Custom data for advanced light types.
|
|
75
|
+
/**
|
|
76
|
+
* Extra parameters of the light
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* Custom data for advanced light types.
|
|
80
80
|
*/ get extraParams() {
|
|
81
81
|
if (!this._extraParams) {
|
|
82
82
|
this.computeUniforms();
|
|
83
83
|
}
|
|
84
84
|
return this._extraParams;
|
|
85
85
|
}
|
|
86
|
-
/**
|
|
87
|
-
* View matrix of the light
|
|
88
|
-
*
|
|
89
|
-
* @remarks
|
|
90
|
-
* The view matrix of the light is used to transform a point
|
|
91
|
-
* from the world space to the light space.
|
|
86
|
+
/**
|
|
87
|
+
* View matrix of the light
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* The view matrix of the light is used to transform a point
|
|
91
|
+
* from the world space to the light space.
|
|
92
92
|
*/ get viewMatrix() {
|
|
93
93
|
return this.invWorldMatrix;
|
|
94
94
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Sets the intensity of the light
|
|
97
|
-
* @param val - Intensity of the light
|
|
98
|
-
* @returns self
|
|
95
|
+
/**
|
|
96
|
+
* Sets the intensity of the light
|
|
97
|
+
* @param val - Intensity of the light
|
|
98
|
+
* @returns self
|
|
99
99
|
*/ setIntensity(val) {
|
|
100
100
|
if (this._intensity !== val) {
|
|
101
101
|
this._intensity = val;
|
|
@@ -128,26 +128,26 @@ import { LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT, LIGHT_TYPE_R
|
|
|
128
128
|
return false;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
/*
|
|
132
|
-
export abstract class AmbientLight extends BaseLight {
|
|
133
|
-
constructor(scene: Scene, type: number) {
|
|
134
|
-
super(scene, type);
|
|
135
|
-
}
|
|
136
|
-
isAmbientLight(): this is AmbientLight {
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
*/ /**
|
|
141
|
-
* Base class for any kind of puncual light
|
|
142
|
-
* @public
|
|
131
|
+
/*
|
|
132
|
+
export abstract class AmbientLight extends BaseLight {
|
|
133
|
+
constructor(scene: Scene, type: number) {
|
|
134
|
+
super(scene, type);
|
|
135
|
+
}
|
|
136
|
+
isAmbientLight(): this is AmbientLight {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
*/ /**
|
|
141
|
+
* Base class for any kind of puncual light
|
|
142
|
+
* @public
|
|
143
143
|
*/ class PunctualLight extends BaseLight {
|
|
144
144
|
/** @internal */ _color;
|
|
145
145
|
/** @internal */ _castShadow;
|
|
146
146
|
/** @internal */ _shadowMapper;
|
|
147
|
-
/**
|
|
148
|
-
* Creates an instance of punctual light
|
|
149
|
-
* @param scene - The scene to which the punctual light belongs
|
|
150
|
-
* @param type - The light type
|
|
147
|
+
/**
|
|
148
|
+
* Creates an instance of punctual light
|
|
149
|
+
* @param scene - The scene to which the punctual light belongs
|
|
150
|
+
* @param type - The light type
|
|
151
151
|
*/ constructor(scene, type){
|
|
152
152
|
super(scene, type);
|
|
153
153
|
this.ensurePunctualState();
|
|
@@ -170,10 +170,10 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
170
170
|
set color(color) {
|
|
171
171
|
this.setColor(color);
|
|
172
172
|
}
|
|
173
|
-
/**
|
|
174
|
-
* Sets color of the light
|
|
175
|
-
* @param color - The color to set
|
|
176
|
-
* @returns self
|
|
173
|
+
/**
|
|
174
|
+
* Sets color of the light
|
|
175
|
+
* @param color - The color to set
|
|
176
|
+
* @returns self
|
|
177
177
|
*/ setColor(color) {
|
|
178
178
|
this.ensurePunctualState();
|
|
179
179
|
this._color.set(color);
|
|
@@ -187,10 +187,10 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
187
187
|
set castShadow(b) {
|
|
188
188
|
this.setCastShadow(b);
|
|
189
189
|
}
|
|
190
|
-
/**
|
|
191
|
-
* Sets whether this light casts shadows
|
|
192
|
-
* @param b - true if the light casts shadows
|
|
193
|
-
* @returns self
|
|
190
|
+
/**
|
|
191
|
+
* Sets whether this light casts shadows
|
|
192
|
+
* @param b - true if the light casts shadows
|
|
193
|
+
* @returns self
|
|
194
194
|
*/ setCastShadow(b) {
|
|
195
195
|
this.ensurePunctualState();
|
|
196
196
|
if (this._castShadow !== !!b) {
|
|
@@ -205,9 +205,9 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
205
205
|
this.ensurePunctualState();
|
|
206
206
|
return this._shadowMapper;
|
|
207
207
|
}
|
|
208
|
-
/**
|
|
209
|
-
* {@inheritDoc BaseLight.isPunctualLight}
|
|
210
|
-
* @override
|
|
208
|
+
/**
|
|
209
|
+
* {@inheritDoc BaseLight.isPunctualLight}
|
|
210
|
+
* @override
|
|
211
211
|
*/ isPunctualLight() {
|
|
212
212
|
return true;
|
|
213
213
|
}
|
|
@@ -222,14 +222,14 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
222
222
|
}
|
|
223
223
|
/** @internal */ computeUniforms() {}
|
|
224
224
|
}
|
|
225
|
-
/**
|
|
226
|
-
* Directional light
|
|
227
|
-
* @public
|
|
225
|
+
/**
|
|
226
|
+
* Directional light
|
|
227
|
+
* @public
|
|
228
228
|
*/ class DirectionalLight extends PunctualLight {
|
|
229
229
|
static _currentSunLight = new WeakMap();
|
|
230
|
-
/**
|
|
231
|
-
* Creates an instance of directional light
|
|
232
|
-
* @param scene - The scene to which the light belongs
|
|
230
|
+
/**
|
|
231
|
+
* Creates an instance of directional light
|
|
232
|
+
* @param scene - The scene to which the light belongs
|
|
233
233
|
*/ constructor(scene){
|
|
234
234
|
super(scene, LIGHT_TYPE_DIRECTIONAL);
|
|
235
235
|
this.intensity = 10;
|
|
@@ -251,11 +251,11 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
251
251
|
ref.set(light);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
-
/**
|
|
255
|
-
* true if the light was defined as sun light
|
|
256
|
-
*
|
|
257
|
-
* @remarks
|
|
258
|
-
* Only one directional light will be marked as sun light.
|
|
254
|
+
/**
|
|
255
|
+
* true if the light was defined as sun light
|
|
256
|
+
*
|
|
257
|
+
* @remarks
|
|
258
|
+
* Only one directional light will be marked as sun light.
|
|
259
259
|
**/ get sunLight() {
|
|
260
260
|
return DirectionalLight.getSunLight(this.scene) === this;
|
|
261
261
|
}
|
|
@@ -266,9 +266,9 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
266
266
|
DirectionalLight.setSunLight(this.scene, null);
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
/**
|
|
270
|
-
* {@inheritDoc BaseLight.isDirectionLight}
|
|
271
|
-
* @override
|
|
269
|
+
/**
|
|
270
|
+
* {@inheritDoc BaseLight.isDirectionLight}
|
|
271
|
+
* @override
|
|
272
272
|
*/ isDirectionLight() {
|
|
273
273
|
return true;
|
|
274
274
|
}
|
|
@@ -284,20 +284,20 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
284
284
|
this._extraParams = new Vector4(0, 0, 0, this.lightType);
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
/**
|
|
288
|
-
* Point light
|
|
289
|
-
* @public
|
|
287
|
+
/**
|
|
288
|
+
* Point light
|
|
289
|
+
* @public
|
|
290
290
|
*/ class PointLight extends PunctualLight {
|
|
291
291
|
/** @internal */ _range;
|
|
292
292
|
/** @internal */ _diffuseScale;
|
|
293
293
|
/** @internal */ _specularScale;
|
|
294
294
|
/** @internal */ _sourceRadius;
|
|
295
|
-
/**
|
|
296
|
-
* Creates an instance of point light
|
|
297
|
-
* @param scene - The scene to which the light belongs
|
|
295
|
+
/**
|
|
296
|
+
* Creates an instance of point light
|
|
297
|
+
* @param scene - The scene to which the light belongs
|
|
298
298
|
*/ constructor(scene){
|
|
299
299
|
super(scene, LIGHT_TYPE_POINT);
|
|
300
|
-
this._range =
|
|
300
|
+
this._range = 0;
|
|
301
301
|
this._diffuseScale = 1;
|
|
302
302
|
this._specularScale = 1;
|
|
303
303
|
this._sourceRadius = 0;
|
|
@@ -327,10 +327,10 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
327
327
|
set sourceRadius(val) {
|
|
328
328
|
this.setSourceRadius(val);
|
|
329
329
|
}
|
|
330
|
-
/**
|
|
331
|
-
* Sets the range of the light
|
|
332
|
-
* @param val - The value to set
|
|
333
|
-
* @returns self
|
|
330
|
+
/**
|
|
331
|
+
* Sets the range of the light
|
|
332
|
+
* @param val - The value to set
|
|
333
|
+
* @returns self
|
|
334
334
|
*/ setRange(val) {
|
|
335
335
|
val = val < 0 ? 0 : val;
|
|
336
336
|
if (this._range !== val) {
|
|
@@ -340,10 +340,10 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
340
340
|
}
|
|
341
341
|
return this;
|
|
342
342
|
}
|
|
343
|
-
/**
|
|
344
|
-
* Sets the diffuse scale of the light
|
|
345
|
-
* @param val - The value to set
|
|
346
|
-
* @returns self
|
|
343
|
+
/**
|
|
344
|
+
* Sets the diffuse scale of the light
|
|
345
|
+
* @param val - The value to set
|
|
346
|
+
* @returns self
|
|
347
347
|
*/ setDiffuseScale(val) {
|
|
348
348
|
val = val < 0 ? 0 : val;
|
|
349
349
|
if (this._diffuseScale !== val) {
|
|
@@ -352,10 +352,10 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
352
352
|
}
|
|
353
353
|
return this;
|
|
354
354
|
}
|
|
355
|
-
/**
|
|
356
|
-
* Sets the specular scale of the light
|
|
357
|
-
* @param val - The value to set
|
|
358
|
-
* @returns self
|
|
355
|
+
/**
|
|
356
|
+
* Sets the specular scale of the light
|
|
357
|
+
* @param val - The value to set
|
|
358
|
+
* @returns self
|
|
359
359
|
*/ setSpecularScale(val) {
|
|
360
360
|
val = val < 0 ? 0 : val;
|
|
361
361
|
if (this._specularScale !== val) {
|
|
@@ -364,10 +364,10 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
364
364
|
}
|
|
365
365
|
return this;
|
|
366
366
|
}
|
|
367
|
-
/**
|
|
368
|
-
* Sets the source radius of the light
|
|
369
|
-
* @param val - The value to set
|
|
370
|
-
* @returns self
|
|
367
|
+
/**
|
|
368
|
+
* Sets the source radius of the light
|
|
369
|
+
* @param val - The value to set
|
|
370
|
+
* @returns self
|
|
371
371
|
*/ setSourceRadius(val) {
|
|
372
372
|
val = val < 0 ? 0 : val;
|
|
373
373
|
if (this._sourceRadius !== val) {
|
|
@@ -376,39 +376,41 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
376
376
|
}
|
|
377
377
|
return this;
|
|
378
378
|
}
|
|
379
|
-
/**
|
|
380
|
-
* {@inheritDoc BaseLight.isPointLight}
|
|
381
|
-
* @override
|
|
379
|
+
/**
|
|
380
|
+
* {@inheritDoc BaseLight.isPointLight}
|
|
381
|
+
* @override
|
|
382
382
|
*/ isPointLight() {
|
|
383
383
|
return true;
|
|
384
384
|
}
|
|
385
385
|
/** @internal */ computeBoundingVolume() {
|
|
386
|
+
const range = this.positionAndRange.w;
|
|
386
387
|
const bbox = new BoundingBox();
|
|
387
|
-
bbox.minPoint = new Vector3(-
|
|
388
|
-
bbox.maxPoint = new Vector3(
|
|
388
|
+
bbox.minPoint = new Vector3(-range, -range, -range);
|
|
389
|
+
bbox.maxPoint = new Vector3(range, range, range);
|
|
389
390
|
return bbox;
|
|
390
391
|
}
|
|
391
392
|
/** @internal */ computeUniforms() {
|
|
392
393
|
const a = this.worldMatrix.getRow(3);
|
|
393
394
|
const b = this.worldMatrix.getRow(2);
|
|
394
|
-
this.
|
|
395
|
+
const range = this.range <= 0 ? 32 * Math.sqrt(Math.max(0.0001, this.intensity * Math.max(this._diffuseScale, this._specularScale))) : this.range;
|
|
396
|
+
this._positionRange = new Vector4(a.x, a.y, a.z, range);
|
|
395
397
|
this._directionCutoff = new Vector4(b.x, b.y, b.z, -1);
|
|
396
398
|
this._diffuseIntensity = new Vector4(this.color.x, this.color.y, this.color.z, this.intensity);
|
|
397
399
|
this._extraParams = new Vector4(this._diffuseScale, this._specularScale, this._sourceRadius, this.lightType);
|
|
398
400
|
}
|
|
399
401
|
}
|
|
400
|
-
/**
|
|
401
|
-
* Spot light
|
|
402
|
-
* @public
|
|
402
|
+
/**
|
|
403
|
+
* Spot light
|
|
404
|
+
* @public
|
|
403
405
|
*/ class SpotLight extends PunctualLight {
|
|
404
406
|
/** @internal */ _range;
|
|
405
407
|
/** @internal */ _cutoff;
|
|
406
|
-
/**
|
|
407
|
-
* Creates an instance of spot light
|
|
408
|
-
* @param scene - The scene to which the light belongs
|
|
408
|
+
/**
|
|
409
|
+
* Creates an instance of spot light
|
|
410
|
+
* @param scene - The scene to which the light belongs
|
|
409
411
|
*/ constructor(scene){
|
|
410
412
|
super(scene, LIGHT_TYPE_SPOT);
|
|
411
|
-
this._range =
|
|
413
|
+
this._range = 0;
|
|
412
414
|
this._cutoff = Math.cos(Math.PI / 4);
|
|
413
415
|
this.invalidateBoundingVolume();
|
|
414
416
|
}
|
|
@@ -418,10 +420,10 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
418
420
|
set range(val) {
|
|
419
421
|
this.setRange(val);
|
|
420
422
|
}
|
|
421
|
-
/**
|
|
422
|
-
* Sets the range of the light
|
|
423
|
-
* @param val - The value to set
|
|
424
|
-
* @returns self
|
|
423
|
+
/**
|
|
424
|
+
* Sets the range of the light
|
|
425
|
+
* @param val - The value to set
|
|
426
|
+
* @returns self
|
|
425
427
|
*/ setRange(val) {
|
|
426
428
|
val = val < 0 ? 0 : val;
|
|
427
429
|
if (this._range !== val) {
|
|
@@ -437,10 +439,10 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
437
439
|
set cutoff(val) {
|
|
438
440
|
this.setCutoff(val);
|
|
439
441
|
}
|
|
440
|
-
/**
|
|
441
|
-
* Sets the cutoff of the light
|
|
442
|
-
* @param val - The value to set
|
|
443
|
-
* @returns self
|
|
442
|
+
/**
|
|
443
|
+
* Sets the cutoff of the light
|
|
444
|
+
* @param val - The value to set
|
|
445
|
+
* @returns self
|
|
444
446
|
*/ setCutoff(val) {
|
|
445
447
|
val = val < 0 ? 0 : val;
|
|
446
448
|
if (this._cutoff !== val) {
|
|
@@ -450,39 +452,41 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
450
452
|
}
|
|
451
453
|
return this;
|
|
452
454
|
}
|
|
453
|
-
/**
|
|
454
|
-
* {@inheritDoc BaseLight.isSpotLight}
|
|
455
|
-
* @override
|
|
455
|
+
/**
|
|
456
|
+
* {@inheritDoc BaseLight.isSpotLight}
|
|
457
|
+
* @override
|
|
456
458
|
*/ isSpotLight() {
|
|
457
459
|
return true;
|
|
458
460
|
}
|
|
459
461
|
/** @internal */ computeBoundingVolume() {
|
|
460
462
|
const bbox = new BoundingBox();
|
|
461
463
|
const cosCutoff = Math.cos(this._cutoff);
|
|
462
|
-
const
|
|
464
|
+
const range = this.positionAndRange.w;
|
|
465
|
+
const r = range / cosCutoff * Math.sqrt(1 - cosCutoff * cosCutoff);
|
|
463
466
|
bbox.minPoint = new Vector3(-r, -r, 0);
|
|
464
|
-
bbox.maxPoint = new Vector3(r, r,
|
|
467
|
+
bbox.maxPoint = new Vector3(r, r, range);
|
|
465
468
|
return bbox;
|
|
466
469
|
}
|
|
467
470
|
/** @internal */ computeUniforms() {
|
|
468
471
|
const a = this.worldMatrix.getRow(3);
|
|
469
472
|
const b = this.worldMatrix.getRow(2).scaleBy(-1);
|
|
470
|
-
this.
|
|
473
|
+
const range = this.range <= 0 ? 32 * Math.sqrt(Math.max(0.0001, this.intensity)) : this.range;
|
|
474
|
+
this._positionRange = new Vector4(a.x, a.y, a.z, range);
|
|
471
475
|
this._directionCutoff = new Vector4(b.x, b.y, b.z, this.cutoff);
|
|
472
476
|
this._diffuseIntensity = new Vector4(this.color.x, this.color.y, this.color.z, this.intensity);
|
|
473
477
|
this._extraParams = new Vector4(0, 0, 0, this.lightType);
|
|
474
478
|
}
|
|
475
479
|
}
|
|
476
|
-
/**
|
|
477
|
-
* Rectangular area light
|
|
478
|
-
* @public
|
|
480
|
+
/**
|
|
481
|
+
* Rectangular area light
|
|
482
|
+
* @public
|
|
479
483
|
*/ class RectLight extends PunctualLight {
|
|
480
484
|
/** @internal */ _range;
|
|
481
485
|
/** @internal */ _width;
|
|
482
486
|
/** @internal */ _height;
|
|
483
|
-
/**
|
|
484
|
-
* Creates an instance of rect light
|
|
485
|
-
* @param scene - The scene to which the light belongs
|
|
487
|
+
/**
|
|
488
|
+
* Creates an instance of rect light
|
|
489
|
+
* @param scene - The scene to which the light belongs
|
|
486
490
|
*/ constructor(scene){
|
|
487
491
|
super(scene, LIGHT_TYPE_RECT);
|
|
488
492
|
this._range = 10;
|
|
@@ -496,10 +500,10 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
496
500
|
set range(val) {
|
|
497
501
|
this.setRange(val);
|
|
498
502
|
}
|
|
499
|
-
/**
|
|
500
|
-
* Sets the range of the light
|
|
501
|
-
* @param val - The value to set
|
|
502
|
-
* @returns self
|
|
503
|
+
/**
|
|
504
|
+
* Sets the range of the light
|
|
505
|
+
* @param val - The value to set
|
|
506
|
+
* @returns self
|
|
503
507
|
*/ setRange(val) {
|
|
504
508
|
val = val < 0 ? 0 : val;
|
|
505
509
|
if (this._range !== val) {
|
|
@@ -515,10 +519,10 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
515
519
|
set width(val) {
|
|
516
520
|
this.setWidth(val);
|
|
517
521
|
}
|
|
518
|
-
/**
|
|
519
|
-
* Sets the width of the light
|
|
520
|
-
* @param val - The value to set
|
|
521
|
-
* @returns self
|
|
522
|
+
/**
|
|
523
|
+
* Sets the width of the light
|
|
524
|
+
* @param val - The value to set
|
|
525
|
+
* @returns self
|
|
522
526
|
*/ setWidth(val) {
|
|
523
527
|
val = val < 0 ? 0 : val;
|
|
524
528
|
if (this._width !== val) {
|
|
@@ -534,10 +538,10 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
534
538
|
set height(val) {
|
|
535
539
|
this.setHeight(val);
|
|
536
540
|
}
|
|
537
|
-
/**
|
|
538
|
-
* Sets the height of the light
|
|
539
|
-
* @param val - The value to set
|
|
540
|
-
* @returns self
|
|
541
|
+
/**
|
|
542
|
+
* Sets the height of the light
|
|
543
|
+
* @param val - The value to set
|
|
544
|
+
* @returns self
|
|
541
545
|
*/ setHeight(val) {
|
|
542
546
|
val = val < 0 ? 0 : val;
|
|
543
547
|
if (this._height !== val) {
|
|
@@ -547,14 +551,14 @@ export abstract class AmbientLight extends BaseLight {
|
|
|
547
551
|
}
|
|
548
552
|
return this;
|
|
549
553
|
}
|
|
550
|
-
/**
|
|
551
|
-
* {@inheritDoc BaseLight.isRectLight}
|
|
552
|
-
* @override
|
|
554
|
+
/**
|
|
555
|
+
* {@inheritDoc BaseLight.isRectLight}
|
|
556
|
+
* @override
|
|
553
557
|
*/ isRectLight() {
|
|
554
558
|
return true;
|
|
555
559
|
}
|
|
556
|
-
/**
|
|
557
|
-
* Rect light supports shadow in current pipeline
|
|
560
|
+
/**
|
|
561
|
+
* Rect light supports shadow in current pipeline
|
|
558
562
|
*/ /** @internal */ computeBoundingVolume() {
|
|
559
563
|
const bbox = new BoundingBox();
|
|
560
564
|
const r = this._range;
|