@zephyr3d/scene 0.1.0 → 0.1.1
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 +46 -0
- package/dist/animation/animation.js +28 -28
- package/dist/animation/skeleton.js +14 -14
- package/dist/animation/usertrack.js +9 -9
- package/dist/app.js +31 -31
- package/dist/asset/assetmanager.js +50 -50
- package/dist/asset/builtin.js +157 -157
- package/dist/asset/loaders/dds/dds_loader.js +11 -11
- package/dist/asset/loaders/gltf/gltf_loader.js +10 -10
- package/dist/asset/loaders/hdr/hdr.js +5 -5
- package/dist/asset/loaders/image/tga_Loader.js +3 -3
- package/dist/asset/loaders/image/webimage_loader.js +3 -3
- package/dist/asset/loaders/loader.js +19 -19
- package/dist/asset/model.js +57 -57
- package/dist/blitter/blitter.js +35 -35
- package/dist/blitter/box.js +24 -24
- package/dist/blitter/depthlimitedgaussion.js +3 -3
- package/dist/blitter/gaussianblur.js +21 -21
- package/dist/camera/camera.js +68 -68
- package/dist/index.d.ts +2 -0
- package/dist/material/grassmaterial.js +17 -17
- package/dist/material/lambert.js +3 -3
- package/dist/material/lightmodel.js +362 -362
- package/dist/material/material.js +50 -50
- package/dist/material/meshmaterial.js +48 -48
- package/dist/material/unlit.js +3 -3
- package/dist/posteffect/bloom.js +5 -5
- package/dist/posteffect/compositor.js +16 -16
- package/dist/posteffect/fxaa.js +5 -5
- package/dist/posteffect/grayscale.js +5 -5
- package/dist/posteffect/posteffect.js +42 -42
- package/dist/posteffect/sao.js +5 -5
- package/dist/posteffect/tonemap.js +5 -5
- package/dist/posteffect/water.js +6 -6
- package/dist/render/cull_visitor.js +12 -12
- package/dist/render/depth_pass.js +8 -8
- package/dist/render/envlight.js +104 -104
- package/dist/render/render_queue.js +33 -33
- package/dist/render/renderpass.js +18 -18
- package/dist/render/renderscheme.js +14 -14
- package/dist/render/scatteringlut.js +3 -3
- package/dist/render/sky.js +38 -38
- package/dist/render/temporalcache.js +4 -4
- package/dist/render/watermesh.js +5 -5
- package/dist/scene/graph_node.js +25 -25
- package/dist/scene/octree.js +191 -191
- package/dist/scene/scene.js +37 -37
- package/dist/scene/terrain/grass.js +27 -27
- package/dist/scene/terrain/quadtree.js +45 -45
- package/dist/shaders/framework.js +161 -161
- package/dist/shaders/lighting.js +7 -7
- package/dist/shaders/noise.js +43 -43
- package/dist/shadow/shadowmapper.js +76 -76
- package/dist/shadow/ssm.js +34 -34
- package/dist/utility/bounding_volume.js +30 -27
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/shprojection.js +14 -14
- package/package.json +70 -70
- package/dist/material/mixins/texture.js +0 -110
- package/dist/material/mixins/texture.js.map +0 -1
|
@@ -3,21 +3,21 @@ import { OctreeNode } from '../scene/octree.js';
|
|
|
3
3
|
import { RENDER_PASS_TYPE_SHADOWMAP } from '../values.js';
|
|
4
4
|
import { GraphNode } from '../scene/graph_node.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Node visitor for culling
|
|
8
|
-
* @public
|
|
6
|
+
/**
|
|
7
|
+
* Node visitor for culling
|
|
8
|
+
* @public
|
|
9
9
|
*/ class CullVisitor {
|
|
10
10
|
/** @internal */ _primaryCamera;
|
|
11
11
|
/** @internal */ _camera;
|
|
12
12
|
/** @internal */ _skipClipTest;
|
|
13
13
|
/** @internal */ _renderQueue;
|
|
14
14
|
/** @internal */ _renderPass;
|
|
15
|
-
/**
|
|
16
|
-
* Creates an instance of CullVisitor
|
|
17
|
-
* @param renderPass - Render pass for the culling task
|
|
18
|
-
* @param camera - Camera that will be used for culling
|
|
19
|
-
* @param rendeQueue - RenderQueue
|
|
20
|
-
* @param viewPoint - Camera position of the primary render pass
|
|
15
|
+
/**
|
|
16
|
+
* Creates an instance of CullVisitor
|
|
17
|
+
* @param renderPass - Render pass for the culling task
|
|
18
|
+
* @param camera - Camera that will be used for culling
|
|
19
|
+
* @param rendeQueue - RenderQueue
|
|
20
|
+
* @param viewPoint - Camera position of the primary render pass
|
|
21
21
|
*/ constructor(renderPass, camera, renderQueue, primaryCamera){
|
|
22
22
|
this._primaryCamera = primaryCamera;
|
|
23
23
|
this._camera = camera;
|
|
@@ -46,9 +46,9 @@ import { GraphNode } from '../scene/graph_node.js';
|
|
|
46
46
|
/** @internal */ push(camera, drawable, renderOrder) {
|
|
47
47
|
this.renderQueue.push(camera, drawable, renderOrder);
|
|
48
48
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Visits a node
|
|
51
|
-
* @param target - The node to be visit
|
|
49
|
+
/**
|
|
50
|
+
* Visits a node
|
|
51
|
+
* @param target - The node to be visit
|
|
52
52
|
*/ visit(target) {
|
|
53
53
|
if (target instanceof OctreeNode) {
|
|
54
54
|
return this.visitOctreeNode(target);
|
|
@@ -4,15 +4,15 @@ import { ShaderFramework } from '../shaders/framework.js';
|
|
|
4
4
|
import '@zephyr3d/device';
|
|
5
5
|
import { Application } from '../app.js';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Depth render pass
|
|
9
|
-
*
|
|
10
|
-
* Scene depth render pass
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
7
|
+
/**
|
|
8
|
+
* Depth render pass
|
|
9
|
+
*
|
|
10
|
+
* Scene depth render pass
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
13
|
*/ class DepthRenderPass extends RenderPass {
|
|
14
|
-
/**
|
|
15
|
-
* Creates an instance of DepthRenderPass
|
|
14
|
+
/**
|
|
15
|
+
* Creates an instance of DepthRenderPass
|
|
16
16
|
*/ constructor(){
|
|
17
17
|
super(RENDER_PASS_TYPE_DEPTH_ONLY);
|
|
18
18
|
}
|
package/dist/render/envlight.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
import { Vector4 } from '@zephyr3d/base';
|
|
2
2
|
import { Application } from '../app.js';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Base class for any kind of environment light
|
|
6
|
-
* @public
|
|
4
|
+
/**
|
|
5
|
+
* Base class for any kind of environment light
|
|
6
|
+
* @public
|
|
7
7
|
*/ class EnvironmentLighting {
|
|
8
|
-
/**
|
|
9
|
-
* Whether this is an instance of EnvIBL
|
|
10
|
-
* @returns true if this is an instance of EnvIBL
|
|
8
|
+
/**
|
|
9
|
+
* Whether this is an instance of EnvIBL
|
|
10
|
+
* @returns true if this is an instance of EnvIBL
|
|
11
11
|
*/ isIBL() {
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Whether this is an instance of EnvConstantAmbient
|
|
16
|
-
* @returns true if this is an instance of EnvConstantAmbient
|
|
14
|
+
/**
|
|
15
|
+
* Whether this is an instance of EnvConstantAmbient
|
|
16
|
+
* @returns true if this is an instance of EnvConstantAmbient
|
|
17
17
|
*/ isConstant() {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Whether this is an instance of EnvHemisphericAmbient
|
|
22
|
-
* @returns true if this is an instance of EnvHemisphericAmbient
|
|
20
|
+
/**
|
|
21
|
+
* Whether this is an instance of EnvHemisphericAmbient
|
|
22
|
+
* @returns true if this is an instance of EnvHemisphericAmbient
|
|
23
23
|
*/ isHemispheric() {
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* IBL based environment lighting
|
|
29
|
-
* @public
|
|
27
|
+
/**
|
|
28
|
+
* IBL based environment lighting
|
|
29
|
+
* @public
|
|
30
30
|
*/ class EnvIBL extends EnvironmentLighting {
|
|
31
31
|
/** @internal */ static USAGE_IBL_RADIANCE_MAP = 'usage_ibl_radiance_map';
|
|
32
32
|
/** @internal */ static USAGE_IBL_RADIANCE_MAP_MAX_LOD = 'usage_ibl_radiance_map_maxlod';
|
|
33
33
|
/** @internal */ static USAGE_IBL_IRRADIANCE_MAP = 'usage_ibl_irradiance_map';
|
|
34
34
|
/** @internal */ _radianceMap;
|
|
35
35
|
/** @internal */ _irradianceMap;
|
|
36
|
-
/**
|
|
37
|
-
* Creates an instance of EnvIBL
|
|
38
|
-
* @param radianceMap - The radiance map
|
|
39
|
-
* @param irradianceMap - The irradiance map
|
|
36
|
+
/**
|
|
37
|
+
* Creates an instance of EnvIBL
|
|
38
|
+
* @param radianceMap - The radiance map
|
|
39
|
+
* @param irradianceMap - The irradiance map
|
|
40
40
|
*/ constructor(radianceMap, irradianceMap){
|
|
41
41
|
super();
|
|
42
42
|
this._radianceMap = radianceMap || null;
|
|
43
43
|
this._irradianceMap = irradianceMap || null;
|
|
44
44
|
}
|
|
45
|
-
/**
|
|
46
|
-
* {@inheritDoc EnvironmentLighting.getType}
|
|
47
|
-
* @override
|
|
45
|
+
/**
|
|
46
|
+
* {@inheritDoc EnvironmentLighting.getType}
|
|
47
|
+
* @override
|
|
48
48
|
*/ getType() {
|
|
49
49
|
return 'ibl';
|
|
50
50
|
}
|
|
@@ -60,9 +60,9 @@ import { Application } from '../app.js';
|
|
|
60
60
|
set irradianceMap(tex) {
|
|
61
61
|
this._irradianceMap = tex;
|
|
62
62
|
}
|
|
63
|
-
/**
|
|
64
|
-
* {@inheritDoc EnvironmentLighting.initShaderBindings}
|
|
65
|
-
* @override
|
|
63
|
+
/**
|
|
64
|
+
* {@inheritDoc EnvironmentLighting.initShaderBindings}
|
|
65
|
+
* @override
|
|
66
66
|
*/ initShaderBindings(pb) {
|
|
67
67
|
if (pb.shaderKind === 'fragment') {
|
|
68
68
|
pb.getGlobalScope().iblRadianceMap = pb.texCube().uniform(0).tag(EnvIBL.USAGE_IBL_RADIANCE_MAP);
|
|
@@ -70,9 +70,9 @@ import { Application } from '../app.js';
|
|
|
70
70
|
pb.getGlobalScope().radianceMaxLod = pb.float('radianceMaxLod').uniform(0).tag(EnvIBL.USAGE_IBL_RADIANCE_MAP_MAX_LOD);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
/**
|
|
74
|
-
* {@inheritDoc EnvironmentLighting.updateBindGroup}
|
|
75
|
-
* @override
|
|
73
|
+
/**
|
|
74
|
+
* {@inheritDoc EnvironmentLighting.updateBindGroup}
|
|
75
|
+
* @override
|
|
76
76
|
*/ updateBindGroup(bg) {
|
|
77
77
|
if (this._radianceMap) {
|
|
78
78
|
bg.setValue('radianceMaxLod', this._radianceMap.mipLevelCount - 1);
|
|
@@ -82,49 +82,49 @@ import { Application } from '../app.js';
|
|
|
82
82
|
bg.setTexture('iblIrradianceMap', this._irradianceMap);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
/**
|
|
86
|
-
* {@inheritDoc EnvironmentLighting.getRadiance}
|
|
87
|
-
* @override
|
|
85
|
+
/**
|
|
86
|
+
* {@inheritDoc EnvironmentLighting.getRadiance}
|
|
87
|
+
* @override
|
|
88
88
|
*/ getRadiance(scope, refl, roughness) {
|
|
89
89
|
const pb = scope.$builder;
|
|
90
90
|
return Application.instance.device.getDeviceCaps().shaderCaps.supportShaderTextureLod ? pb.textureSampleLevel(scope.iblRadianceMap, refl, pb.mul(roughness, scope.radianceMaxLod)).rgb : pb.textureSample(scope.iblRadianceMap, refl).rgb;
|
|
91
91
|
}
|
|
92
|
-
/**
|
|
93
|
-
* {@inheritDoc EnvironmentLighting.getIrradiance}
|
|
94
|
-
* @override
|
|
92
|
+
/**
|
|
93
|
+
* {@inheritDoc EnvironmentLighting.getIrradiance}
|
|
94
|
+
* @override
|
|
95
95
|
*/ getIrradiance(scope, normal) {
|
|
96
96
|
const pb = scope.$builder;
|
|
97
97
|
return pb.textureSampleLevel(scope.iblIrradianceMap, normal, 0).rgb;
|
|
98
98
|
}
|
|
99
|
-
/**
|
|
100
|
-
* {@inheritDoc EnvironmentLighting.hasRadiance}
|
|
101
|
-
* @override
|
|
99
|
+
/**
|
|
100
|
+
* {@inheritDoc EnvironmentLighting.hasRadiance}
|
|
101
|
+
* @override
|
|
102
102
|
*/ hasRadiance() {
|
|
103
103
|
return !!this._radianceMap;
|
|
104
104
|
}
|
|
105
|
-
/**
|
|
106
|
-
* {@inheritDoc EnvironmentLighting.hasIrradiance}
|
|
107
|
-
* @override
|
|
105
|
+
/**
|
|
106
|
+
* {@inheritDoc EnvironmentLighting.hasIrradiance}
|
|
107
|
+
* @override
|
|
108
108
|
*/ hasIrradiance() {
|
|
109
109
|
return !!this._irradianceMap;
|
|
110
110
|
}
|
|
111
|
-
/**
|
|
112
|
-
* {@inheritDoc EnvironmentLighting.isIBL}
|
|
113
|
-
* @override
|
|
111
|
+
/**
|
|
112
|
+
* {@inheritDoc EnvironmentLighting.isIBL}
|
|
113
|
+
* @override
|
|
114
114
|
*/ isIBL() {
|
|
115
115
|
return true;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Constant ambient light
|
|
120
|
-
* @public
|
|
118
|
+
/**
|
|
119
|
+
* Constant ambient light
|
|
120
|
+
* @public
|
|
121
121
|
*/ class EnvConstantAmbient extends EnvironmentLighting {
|
|
122
122
|
/** @internal */ static USAGE_CONSTANT_AMBIENT_LIGHTING = 'usage_env_constant_ambient';
|
|
123
123
|
/** @internal */ static funcNameGetAmbient = 'lib_getConstantAmbient';
|
|
124
124
|
/** @internal */ _ambientColor;
|
|
125
|
-
/**
|
|
126
|
-
* Creates an instance of EnvConstantAmbient
|
|
127
|
-
* @param ambientColor - The ambient color
|
|
125
|
+
/**
|
|
126
|
+
* Creates an instance of EnvConstantAmbient
|
|
127
|
+
* @param ambientColor - The ambient color
|
|
128
128
|
*/ constructor(ambientColor){
|
|
129
129
|
super();
|
|
130
130
|
this._ambientColor = ambientColor ? new Vector4(ambientColor) : new Vector4(0, 0, 0, 1);
|
|
@@ -137,70 +137,70 @@ import { Application } from '../app.js';
|
|
|
137
137
|
this._ambientColor.set(ambientColor);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
/**
|
|
141
|
-
* {@inheritDoc EnvironmentLighting.getType}
|
|
142
|
-
* @override
|
|
140
|
+
/**
|
|
141
|
+
* {@inheritDoc EnvironmentLighting.getType}
|
|
142
|
+
* @override
|
|
143
143
|
*/ getType() {
|
|
144
144
|
return 'constant';
|
|
145
145
|
}
|
|
146
|
-
/**
|
|
147
|
-
* {@inheritDoc EnvironmentLighting.initShaderBindings}
|
|
148
|
-
* @override
|
|
146
|
+
/**
|
|
147
|
+
* {@inheritDoc EnvironmentLighting.initShaderBindings}
|
|
148
|
+
* @override
|
|
149
149
|
*/ initShaderBindings(pb) {
|
|
150
150
|
if (pb.shaderKind === 'fragment') {
|
|
151
151
|
pb.getGlobalScope().ambientLight = pb.vec4().uniform(0).tag(EnvConstantAmbient.USAGE_CONSTANT_AMBIENT_LIGHTING);
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
/**
|
|
155
|
-
* {@inheritDoc EnvironmentLighting.updateBindGroup}
|
|
156
|
-
* @override
|
|
154
|
+
/**
|
|
155
|
+
* {@inheritDoc EnvironmentLighting.updateBindGroup}
|
|
156
|
+
* @override
|
|
157
157
|
*/ updateBindGroup(bg) {
|
|
158
158
|
bg.setValue('ambientLight', this._ambientColor);
|
|
159
159
|
}
|
|
160
|
-
/**
|
|
161
|
-
* {@inheritDoc EnvironmentLighting.getRadiance}
|
|
162
|
-
* @override
|
|
160
|
+
/**
|
|
161
|
+
* {@inheritDoc EnvironmentLighting.getRadiance}
|
|
162
|
+
* @override
|
|
163
163
|
*/ getRadiance(scope, refl, roughness) {
|
|
164
164
|
return null;
|
|
165
165
|
}
|
|
166
|
-
/**
|
|
167
|
-
* {@inheritDoc EnvironmentLighting.getIrradiance}
|
|
168
|
-
* @override
|
|
166
|
+
/**
|
|
167
|
+
* {@inheritDoc EnvironmentLighting.getIrradiance}
|
|
168
|
+
* @override
|
|
169
169
|
*/ getIrradiance(scope, normal) {
|
|
170
170
|
return scope.ambientLight.rgb;
|
|
171
171
|
}
|
|
172
|
-
/**
|
|
173
|
-
* {@inheritDoc EnvironmentLighting.hasRadiance}
|
|
174
|
-
* @override
|
|
172
|
+
/**
|
|
173
|
+
* {@inheritDoc EnvironmentLighting.hasRadiance}
|
|
174
|
+
* @override
|
|
175
175
|
*/ hasRadiance() {
|
|
176
176
|
return false;
|
|
177
177
|
}
|
|
178
|
-
/**
|
|
179
|
-
* {@inheritDoc EnvironmentLighting.hasIrradiance}
|
|
180
|
-
* @override
|
|
178
|
+
/**
|
|
179
|
+
* {@inheritDoc EnvironmentLighting.hasIrradiance}
|
|
180
|
+
* @override
|
|
181
181
|
*/ hasIrradiance() {
|
|
182
182
|
return true;
|
|
183
183
|
}
|
|
184
|
-
/**
|
|
185
|
-
* {@inheritDoc EnvironmentLighting.isConstant}
|
|
186
|
-
* @override
|
|
184
|
+
/**
|
|
185
|
+
* {@inheritDoc EnvironmentLighting.isConstant}
|
|
186
|
+
* @override
|
|
187
187
|
*/ isConstant() {
|
|
188
188
|
return true;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
/**
|
|
192
|
-
* Hemispheric ambient light
|
|
193
|
-
* @public
|
|
191
|
+
/**
|
|
192
|
+
* Hemispheric ambient light
|
|
193
|
+
* @public
|
|
194
194
|
*/ class EnvHemisphericAmbient extends EnvironmentLighting {
|
|
195
195
|
/** @internal */ static USAGE_CONSTANT_AMBIENT_UP = 'usage_env_ambient_up';
|
|
196
196
|
/** @internal */ static USAGE_CONSTANT_AMBIENT_DOWN = 'usage_env_ambient_down';
|
|
197
197
|
/** @internal */ static funcNameGetAmbient = 'lib_getConstantAmbient';
|
|
198
198
|
/** @internal */ _ambientUp;
|
|
199
199
|
/** @internal */ _ambientDown;
|
|
200
|
-
/**
|
|
201
|
-
* Creates an instance of EnvConstantAmbient
|
|
202
|
-
* @param ambientUp - The upside ambient color
|
|
203
|
-
* @param ambientDown - The downside ambient color
|
|
200
|
+
/**
|
|
201
|
+
* Creates an instance of EnvConstantAmbient
|
|
202
|
+
* @param ambientUp - The upside ambient color
|
|
203
|
+
* @param ambientDown - The downside ambient color
|
|
204
204
|
*/ constructor(ambientUp, ambientDown){
|
|
205
205
|
super();
|
|
206
206
|
this._ambientUp = new Vector4(ambientUp);
|
|
@@ -222,57 +222,57 @@ import { Application } from '../app.js';
|
|
|
222
222
|
this._ambientDown.set(color);
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
/**
|
|
226
|
-
* {@inheritDoc EnvironmentLighting.getType}
|
|
227
|
-
* @override
|
|
225
|
+
/**
|
|
226
|
+
* {@inheritDoc EnvironmentLighting.getType}
|
|
227
|
+
* @override
|
|
228
228
|
*/ getType() {
|
|
229
229
|
return 'hemisphere';
|
|
230
230
|
}
|
|
231
|
-
/**
|
|
232
|
-
* {@inheritDoc EnvironmentLighting.initShaderBindings}
|
|
233
|
-
* @override
|
|
231
|
+
/**
|
|
232
|
+
* {@inheritDoc EnvironmentLighting.initShaderBindings}
|
|
233
|
+
* @override
|
|
234
234
|
*/ initShaderBindings(pb) {
|
|
235
235
|
if (pb.shaderKind === 'fragment') {
|
|
236
236
|
pb.getGlobalScope().ambientUp = pb.vec4().uniform(0).tag(EnvHemisphericAmbient.USAGE_CONSTANT_AMBIENT_UP);
|
|
237
237
|
pb.getGlobalScope().ambientDown = pb.vec4().uniform(0).tag(EnvHemisphericAmbient.USAGE_CONSTANT_AMBIENT_DOWN);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
/**
|
|
241
|
-
* {@inheritDoc EnvironmentLighting.updateBindGroup}
|
|
242
|
-
* @override
|
|
240
|
+
/**
|
|
241
|
+
* {@inheritDoc EnvironmentLighting.updateBindGroup}
|
|
242
|
+
* @override
|
|
243
243
|
*/ updateBindGroup(bg) {
|
|
244
244
|
bg.setValue('ambientUp', this._ambientUp);
|
|
245
245
|
bg.setValue('ambientDown', this._ambientDown);
|
|
246
246
|
}
|
|
247
|
-
/**
|
|
248
|
-
* {@inheritDoc EnvironmentLighting.getRadiance}
|
|
249
|
-
* @override
|
|
247
|
+
/**
|
|
248
|
+
* {@inheritDoc EnvironmentLighting.getRadiance}
|
|
249
|
+
* @override
|
|
250
250
|
*/ getRadiance(scope, refl, roughness) {
|
|
251
251
|
return null;
|
|
252
252
|
}
|
|
253
|
-
/**
|
|
254
|
-
* {@inheritDoc EnvironmentLighting.getIrradiance}
|
|
255
|
-
* @override
|
|
253
|
+
/**
|
|
254
|
+
* {@inheritDoc EnvironmentLighting.getIrradiance}
|
|
255
|
+
* @override
|
|
256
256
|
*/ getIrradiance(scope, normal) {
|
|
257
257
|
const pb = scope.$builder;
|
|
258
258
|
const factor = pb.add(pb.mul(normal.y, 0.5), 0.5);
|
|
259
259
|
return pb.mix(scope.ambientDown, scope.ambientUp, factor).rgb;
|
|
260
260
|
}
|
|
261
|
-
/**
|
|
262
|
-
* {@inheritDoc EnvironmentLighting.hasRadiance}
|
|
263
|
-
* @override
|
|
261
|
+
/**
|
|
262
|
+
* {@inheritDoc EnvironmentLighting.hasRadiance}
|
|
263
|
+
* @override
|
|
264
264
|
*/ hasRadiance() {
|
|
265
265
|
return false;
|
|
266
266
|
}
|
|
267
|
-
/**
|
|
268
|
-
* {@inheritDoc EnvironmentLighting.hasIrradiance}
|
|
269
|
-
* @override
|
|
267
|
+
/**
|
|
268
|
+
* {@inheritDoc EnvironmentLighting.hasIrradiance}
|
|
269
|
+
* @override
|
|
270
270
|
*/ hasIrradiance() {
|
|
271
271
|
return true;
|
|
272
272
|
}
|
|
273
|
-
/**
|
|
274
|
-
* {@inheritDoc EnvironmentLighting.isHemispheric}
|
|
275
|
-
* @override
|
|
273
|
+
/**
|
|
274
|
+
* {@inheritDoc EnvironmentLighting.isHemispheric}
|
|
275
|
+
* @override
|
|
276
276
|
*/ isHemispheric() {
|
|
277
277
|
return true;
|
|
278
278
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Application } from '../app.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* A queue that contains the items to be rendered
|
|
5
|
-
* @public
|
|
3
|
+
/**
|
|
4
|
+
* A queue that contains the items to be rendered
|
|
5
|
+
* @public
|
|
6
6
|
*/ class RenderQueue {
|
|
7
7
|
/** @internal */ _itemLists;
|
|
8
8
|
/** @internal */ _renderPass;
|
|
9
9
|
/** @internal */ _shadowedLightList;
|
|
10
10
|
/** @internal */ _unshadowedLightList;
|
|
11
11
|
/** @internal */ _sunLight;
|
|
12
|
-
/**
|
|
13
|
-
* Creates an instance of a render queue
|
|
14
|
-
* @param renderPass - The render pass to which the render queue belongs
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of a render queue
|
|
14
|
+
* @param renderPass - The render pass to which the render queue belongs
|
|
15
15
|
*/ constructor(renderPass){
|
|
16
16
|
this._itemLists = {};
|
|
17
17
|
this._renderPass = renderPass;
|
|
@@ -28,32 +28,32 @@ import { Application } from '../app.js';
|
|
|
28
28
|
/** The render pass to which the render queue belongs */ get renderPass() {
|
|
29
29
|
return this._renderPass;
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Gets the items of the render queue
|
|
31
|
+
/**
|
|
32
|
+
* Gets the items of the render queue
|
|
33
33
|
*/ get items() {
|
|
34
34
|
return this._itemLists;
|
|
35
35
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Gets the shadowed lights
|
|
36
|
+
/**
|
|
37
|
+
* Gets the shadowed lights
|
|
38
38
|
*/ get shadowedLights() {
|
|
39
39
|
return this._shadowedLightList;
|
|
40
40
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Gets the unshadowed lights
|
|
41
|
+
/**
|
|
42
|
+
* Gets the unshadowed lights
|
|
43
43
|
*/ get unshadowedLights() {
|
|
44
44
|
return this._unshadowedLightList;
|
|
45
45
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Gets the maximum batch size of a given device
|
|
48
|
-
* @returns The maximum batch size of the device
|
|
49
|
-
*
|
|
50
|
-
* @internal
|
|
46
|
+
/**
|
|
47
|
+
* Gets the maximum batch size of a given device
|
|
48
|
+
* @returns The maximum batch size of the device
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
51
51
|
*/ getMaxBatchSize() {
|
|
52
52
|
return Application.instance.device.getDeviceCaps().shaderCaps.maxUniformBufferSize / 64;
|
|
53
53
|
}
|
|
54
|
-
/**
|
|
55
|
-
* Push a punctual light
|
|
56
|
-
* @param light - The light to be pushed
|
|
54
|
+
/**
|
|
55
|
+
* Push a punctual light
|
|
56
|
+
* @param light - The light to be pushed
|
|
57
57
|
*/ pushLight(light) {
|
|
58
58
|
if (light.castShadow) {
|
|
59
59
|
this._shadowedLightList.push(light);
|
|
@@ -64,11 +64,11 @@ import { Application } from '../app.js';
|
|
|
64
64
|
this.sunLight = light;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Push an item to the render queue
|
|
69
|
-
* @param camera - The camera for drawing the item
|
|
70
|
-
* @param drawable - The object to be drawn
|
|
71
|
-
* @param renderOrder - Render order of the object
|
|
67
|
+
/**
|
|
68
|
+
* Push an item to the render queue
|
|
69
|
+
* @param camera - The camera for drawing the item
|
|
70
|
+
* @param drawable - The object to be drawn
|
|
71
|
+
* @param renderOrder - Render order of the object
|
|
72
72
|
*/ push(camera, drawable, renderOrder) {
|
|
73
73
|
if (drawable) {
|
|
74
74
|
let itemList = this._itemLists[renderOrder];
|
|
@@ -111,16 +111,16 @@ import { Application } from '../app.js';
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Removes all items in the render queue
|
|
114
|
+
/**
|
|
115
|
+
* Removes all items in the render queue
|
|
116
116
|
*/ clear() {
|
|
117
117
|
this._itemLists = {};
|
|
118
118
|
this._shadowedLightList = [];
|
|
119
119
|
this._unshadowedLightList = [];
|
|
120
120
|
this._sunLight = null;
|
|
121
121
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Sorts the items in the render queue for rendering
|
|
122
|
+
/**
|
|
123
|
+
* Sorts the items in the render queue for rendering
|
|
124
124
|
*/ sortItems() {
|
|
125
125
|
for (const list of Object.values(this._itemLists)){
|
|
126
126
|
list.opaqueList.sort((a, b)=>a.sortDistance - b.sortDistance);
|
|
@@ -133,10 +133,10 @@ import { Application } from '../app.js';
|
|
|
133
133
|
outColor[2] = (index >> 8 && 255) / 255;
|
|
134
134
|
outColor[3] = (index >> 0 && 255) / 255;
|
|
135
135
|
}
|
|
136
|
-
/*
|
|
137
|
-
private decodeInstanceColor(value: Float32Array): number {
|
|
138
|
-
return (value[0] << 24) + (value[1] << 16) + (value[2] << 8) + value[3];
|
|
139
|
-
}
|
|
136
|
+
/*
|
|
137
|
+
private decodeInstanceColor(value: Float32Array): number {
|
|
138
|
+
return (value[0] << 24) + (value[1] << 16) + (value[2] << 8) + value[3];
|
|
139
|
+
}
|
|
140
140
|
*/ setInstanceColors() {
|
|
141
141
|
const nodes = [];
|
|
142
142
|
let id = 0;
|
|
@@ -11,18 +11,18 @@ import '../material/unlit.js';
|
|
|
11
11
|
import '../material/lightmodel.js';
|
|
12
12
|
import { RenderQueue } from './render_queue.js';
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* Base class for any kind of render passes
|
|
16
|
-
* @public
|
|
14
|
+
/**
|
|
15
|
+
* Base class for any kind of render passes
|
|
16
|
+
* @public
|
|
17
17
|
*/ class RenderPass {
|
|
18
18
|
/** @internal */ _type;
|
|
19
19
|
/** @internal */ _globalBindGroups;
|
|
20
20
|
/** @internal */ _clearColor;
|
|
21
21
|
/** @internal */ _clearDepth;
|
|
22
22
|
/** @internal */ _clearStencil;
|
|
23
|
-
/**
|
|
24
|
-
* Creates an instanceof RenderPass
|
|
25
|
-
* @param type - Render pass type
|
|
23
|
+
/**
|
|
24
|
+
* Creates an instanceof RenderPass
|
|
25
|
+
* @param type - Render pass type
|
|
26
26
|
*/ constructor(type){
|
|
27
27
|
this._type = type;
|
|
28
28
|
this._clearColor = new Vector4(0, 0, 0, 1);
|
|
@@ -48,17 +48,17 @@ import { RenderQueue } from './render_queue.js';
|
|
|
48
48
|
set clearStencil(stencil) {
|
|
49
49
|
this._clearStencil = stencil ?? null;
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
52
|
-
* The render pass type
|
|
51
|
+
/**
|
|
52
|
+
* The render pass type
|
|
53
53
|
*/ get type() {
|
|
54
54
|
return this._type;
|
|
55
55
|
}
|
|
56
56
|
/** @internal */ isAutoFlip() {
|
|
57
57
|
return !!(Application.instance.device.getFramebuffer() && Application.instance.device.type === 'webgpu');
|
|
58
58
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Renders a scene
|
|
61
|
-
* @param ctx - Drawing context
|
|
59
|
+
/**
|
|
60
|
+
* Renders a scene
|
|
61
|
+
* @param ctx - Drawing context
|
|
62
62
|
*/ render(ctx, cullCamera, renderQueue) {
|
|
63
63
|
ctx.renderPass = this;
|
|
64
64
|
this.drawScene(ctx, cullCamera ?? ctx.camera, renderQueue);
|
|
@@ -92,8 +92,8 @@ import { RenderQueue } from './render_queue.js';
|
|
|
92
92
|
}
|
|
93
93
|
return bindGroup;
|
|
94
94
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Disposes the render pass
|
|
95
|
+
/**
|
|
96
|
+
* Disposes the render pass
|
|
97
97
|
*/ dispose() {
|
|
98
98
|
for(const k in this._globalBindGroups){
|
|
99
99
|
Material.bindGroupGarbageCollect(this._globalBindGroups[k].bindGroup);
|
|
@@ -114,11 +114,11 @@ import { RenderQueue } from './render_queue.js';
|
|
|
114
114
|
device.reverseVertexWindingOrder(windingReversed);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Culls a scene by a given camera
|
|
119
|
-
* @param ctx - The draw context
|
|
120
|
-
* @param cullCamera - The camera that will be used to cull the scene
|
|
121
|
-
* @returns The cull result
|
|
117
|
+
/**
|
|
118
|
+
* Culls a scene by a given camera
|
|
119
|
+
* @param ctx - The draw context
|
|
120
|
+
* @param cullCamera - The camera that will be used to cull the scene
|
|
121
|
+
* @returns The cull result
|
|
122
122
|
*/ cullScene(ctx, cullCamera) {
|
|
123
123
|
if (cullCamera) {
|
|
124
124
|
const renderQueue = new RenderQueue(this);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Application } from '../app.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Base class for any kind of render scheme
|
|
5
|
-
* @public
|
|
3
|
+
/**
|
|
4
|
+
* Base class for any kind of render scheme
|
|
5
|
+
* @public
|
|
6
6
|
*/ class RenderScheme {
|
|
7
7
|
/** @internal */ _shadowMapFormat;
|
|
8
8
|
/** @internal */ _enableDepthPass;
|
|
9
9
|
/** @internal */ _currentScene;
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of RenderScheme
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of RenderScheme
|
|
12
12
|
*/ constructor(){
|
|
13
13
|
this._shadowMapFormat = null;
|
|
14
14
|
this._enableDepthPass = false;
|
|
@@ -23,10 +23,10 @@ import { Application } from '../app.js';
|
|
|
23
23
|
/** The scene that is currently been rendered */ get currentScene() {
|
|
24
24
|
return this._currentScene;
|
|
25
25
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Renders a scene by given camera
|
|
28
|
-
* @param scene - The scene to be rendered
|
|
29
|
-
* @param camera - The camera that will be used to render the scene
|
|
26
|
+
/**
|
|
27
|
+
* Renders a scene by given camera
|
|
28
|
+
* @param scene - The scene to be rendered
|
|
29
|
+
* @param camera - The camera that will be used to render the scene
|
|
30
30
|
*/ renderScene(scene, camera, compositor) {
|
|
31
31
|
this._currentScene = scene;
|
|
32
32
|
const ctx = {
|
|
@@ -40,14 +40,14 @@ import { Application } from '../app.js';
|
|
|
40
40
|
}
|
|
41
41
|
this._currentScene = null;
|
|
42
42
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Disposes the render scheme
|
|
43
|
+
/**
|
|
44
|
+
* Disposes the render scheme
|
|
45
45
|
*/ dispose() {
|
|
46
46
|
this._dispose();
|
|
47
47
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Gets the texture format for shadow maps
|
|
50
|
-
* @returns Texture format for shadow maps
|
|
48
|
+
/**
|
|
49
|
+
* Gets the texture format for shadow maps
|
|
50
|
+
* @returns Texture format for shadow maps
|
|
51
51
|
*/ getShadowMapFormat() {
|
|
52
52
|
if (!this._shadowMapFormat) {
|
|
53
53
|
const device = Application.instance.device;
|