@zephyr3d/scene 0.4.0 → 0.6.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/dist/animation/animation.js +25 -117
- package/dist/animation/animation.js.map +1 -1
- package/dist/animation/animationset.js +191 -51
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js +6 -18
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +16 -6
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/morphtarget.js +104 -0
- package/dist/animation/morphtarget.js.map +1 -0
- package/dist/animation/morphtrack.js +70 -0
- package/dist/animation/morphtrack.js.map +1 -0
- package/dist/animation/rotationtrack.js +15 -7
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +15 -7
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +107 -5
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/translationtrack.js +15 -7
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app.js +4 -26
- package/dist/app.js.map +1 -1
- package/dist/asset/assetmanager.js +60 -109
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/dds/dds.js +77 -3
- package/dist/asset/loaders/dds/dds.js.map +1 -1
- package/dist/asset/loaders/dds/dds_loader.js +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +287 -40
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/image/tga_Loader.js +1 -1
- package/dist/asset/loaders/image/webimage_loader.js +16 -0
- package/dist/asset/loaders/image/webimage_loader.js.map +1 -1
- package/dist/asset/model.js +16 -9
- package/dist/asset/model.js.map +1 -1
- package/dist/blitter/bilateralblur.js +222 -0
- package/dist/{render/temporalcache.js.map → blitter/bilateralblur.js.map} +1 -1
- package/dist/blitter/blitter.js +9 -3
- package/dist/blitter/blitter.js.map +1 -1
- package/dist/blitter/depthlimitedgaussion.js +96 -39
- package/dist/blitter/depthlimitedgaussion.js.map +1 -1
- package/dist/blitter/gaussianblur.js +21 -21
- package/dist/camera/camera.js +200 -4
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +6406 -5786
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +15 -4
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/lambert.js +26 -17
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +13 -2
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +103 -31
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +5 -4
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +17 -7
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +5 -5
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +16 -7
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +16 -7
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +2 -2
- package/dist/material/mixins/pbr/common.js +454 -19
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/pbrmr.js +28 -6
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +27 -9
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +128 -23
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/unlit.js +8 -4
- package/dist/material/unlit.js.map +1 -1
- package/dist/posteffect/bloom.js +34 -53
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js +48 -58
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js +3 -11
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js +3 -11
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/posteffect.js +4 -0
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/sao.js +55 -48
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/ssr.js +536 -0
- package/dist/{material/lit.js.map → posteffect/ssr.js.map} +1 -1
- package/dist/posteffect/tonemap.js +3 -11
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/posteffect/water.js +306 -340
- package/dist/posteffect/water.js.map +1 -1
- package/dist/render/abuffer_oit.js +2 -2
- package/dist/render/clipmap.js +16 -19
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cull_visitor.js +8 -6
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +30 -14
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +70 -22
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +169 -33
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +989 -0
- package/dist/{shaders/framework.js.map → render/fft_wavegenerator.js.map} +1 -1
- package/dist/render/gerstner_wavegenerator.js +265 -0
- package/dist/{material/standard.js.map → render/gerstner_wavegenerator.js.map} +1 -1
- package/dist/render/globalbindgroup_allocator.js +2 -1
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/hzb.js +273 -0
- package/dist/{material/terrainlightmodel.js.map → render/hzb.js.map} +1 -1
- package/dist/render/lightpass.js +68 -28
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/objectcolorpass.js +51 -0
- package/dist/render/objectcolorpass.js.map +1 -0
- package/dist/render/render_queue.js +211 -158
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderbundle_wrapper.js +79 -0
- package/dist/render/renderbundle_wrapper.js.map +1 -1
- package/dist/render/renderer.js +151 -35
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/renderpass.js +27 -20
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/shadowmap_pass.js +20 -14
- package/dist/render/shadowmap_pass.js.map +1 -1
- package/dist/render/sky.js +12 -13
- package/dist/render/sky.js.map +1 -1
- package/dist/render/watermesh.js +94 -828
- package/dist/render/watermesh.js.map +1 -1
- package/dist/render/wavegenerator.js +8 -0
- package/dist/render/wavegenerator.js.map +1 -0
- package/dist/render/weightedblended_oit.js +11 -28
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/batchgroup.js +60 -14
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +24 -3
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/graph_node.js +0 -14
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/light.js +5 -5
- package/dist/scene/mesh.js +62 -15
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/octree.js +5 -2
- package/dist/scene/octree.js.map +1 -1
- package/dist/scene/raycast_visitor.js +4 -2
- package/dist/scene/raycast_visitor.js.map +1 -1
- package/dist/scene/scene.js +6 -9
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +11 -8
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain/grass.js +10 -2
- package/dist/scene/terrain/grass.js.map +1 -1
- package/dist/scene/terrain/heightfield.js +135 -53
- package/dist/scene/terrain/heightfield.js.map +1 -1
- package/dist/scene/terrain/patch.js +10 -2
- package/dist/scene/terrain/patch.js.map +1 -1
- package/dist/scene/terrain/quadtree.js +2 -2
- package/dist/scene/terrain/terrain.js +1 -1
- package/dist/scene/xform.js +7 -9
- package/dist/scene/xform.js.map +1 -1
- package/dist/shaders/misc.js +10 -1
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +81 -16
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/shadow.js +1 -9
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/ssr.js +442 -0
- package/dist/{material/terrainmat.js.map → shaders/ssr.js.map} +1 -1
- package/dist/shaders/water.js +377 -250
- package/dist/shaders/water.js.map +1 -1
- package/dist/shadow/esm.js +4 -22
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/shadowmapper.js +56 -31
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/vsm.js +4 -24
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/cylinder.js +6 -5
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/utility/bounding_volume.js +1 -53
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/draco/decoder.js +116 -0
- package/dist/utility/draco/decoder.js.map +1 -0
- package/dist/utility/misc.js +93 -0
- package/dist/utility/misc.js.map +1 -0
- package/dist/utility/shprojection.js +2 -7
- package/dist/utility/shprojection.js.map +1 -1
- package/dist/utility/textures/ggxlut.js +213 -0
- package/dist/utility/textures/ggxlut.js.map +1 -0
- package/dist/utility/textures/gradientnoise.js +61 -0
- package/dist/utility/textures/gradientnoise.js.map +1 -0
- package/dist/utility/textures/randomnoise.js +41 -0
- package/dist/utility/textures/randomnoise.js.map +1 -0
- package/dist/values.js +25 -1
- package/dist/values.js.map +1 -1
- package/package.json +5 -8
- package/dist/animation/usertrack.js +0 -47
- package/dist/animation/usertrack.js.map +0 -1
- package/dist/material/grassmat.js +0 -127
- package/dist/material/grassmat.js.map +0 -1
- package/dist/material/lightmodel.js +0 -2074
- package/dist/material/lightmodel.js.map +0 -1
- package/dist/material/lit.js +0 -578
- package/dist/material/mixins/pbr/metallicroughness.js +0 -126
- package/dist/material/mixins/pbr/metallicroughness.js.map +0 -1
- package/dist/material/mixins/pbr/specularglossness.js +0 -104
- package/dist/material/mixins/pbr/specularglossness.js.map +0 -1
- package/dist/material/pbr.js +0 -27
- package/dist/material/pbr.js.map +0 -1
- package/dist/material/standard.js +0 -282
- package/dist/material/terrainlightmodel.js +0 -259
- package/dist/material/terrainmat.js +0 -357
- package/dist/render/depth_pass.js +0 -47
- package/dist/render/depth_pass.js.map +0 -1
- package/dist/render/forward.js +0 -186
- package/dist/render/forward.js.map +0 -1
- package/dist/render/forward_pass.js +0 -137
- package/dist/render/forward_pass.js.map +0 -1
- package/dist/render/helper.js +0 -38
- package/dist/render/helper.js.map +0 -1
- package/dist/render/renderscheme.js +0 -61
- package/dist/render/renderscheme.js.map +0 -1
- package/dist/render/temporalcache.js +0 -222
- package/dist/scene/model.js +0 -111
- package/dist/scene/model.js.map +0 -1
- package/dist/scene/octree_update_visitor.js +0 -20
- package/dist/scene/octree_update_visitor.js.map +0 -1
- package/dist/shaders/builtins.js +0 -110
- package/dist/shaders/builtins.js.map +0 -1
- package/dist/shaders/framework.js +0 -723
- package/dist/shaders/lighting.js +0 -335
- package/dist/shaders/lighting.js.map +0 -1
- package/dist/utility/sheenlut.js +0 -196
- package/dist/utility/sheenlut.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"water.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"water.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/shadow/esm.js
CHANGED
|
@@ -5,22 +5,9 @@ import '@zephyr3d/device';
|
|
|
5
5
|
import { decodeNormalizedFloatFromRGBA, encodeNormalizedFloatToRGBA } from '../shaders/misc.js';
|
|
6
6
|
import { GaussianBlurBlitter } from '../blitter/gaussianblur.js';
|
|
7
7
|
import { computeShadowMapDepth, filterShadowESM } from '../shaders/shadow.js';
|
|
8
|
-
import '../scene/octree.js';
|
|
9
8
|
import { LIGHT_TYPE_POINT } from '../values.js';
|
|
9
|
+
import { ShadowMapper } from './shadowmapper.js';
|
|
10
10
|
import { ShaderHelper } from '../material/shader/helper.js';
|
|
11
|
-
import '../material/lambert.js';
|
|
12
|
-
import '../material/blinn.js';
|
|
13
|
-
import '../material/unlit.js';
|
|
14
|
-
import '../material/meshmaterial.js';
|
|
15
|
-
import '../material/grassmaterial.js';
|
|
16
|
-
import '../material/terrainmaterial.js';
|
|
17
|
-
import '../material/pbrmr.js';
|
|
18
|
-
import '../material/pbrsg.js';
|
|
19
|
-
import '../render/renderer.js';
|
|
20
|
-
import '../render/sky.js';
|
|
21
|
-
import '../render/clipmap.js';
|
|
22
|
-
import { TemporalCache } from '../render/temporalcache.js';
|
|
23
|
-
import '../render/watermesh.js';
|
|
24
11
|
|
|
25
12
|
class BlurBlitter extends GaussianBlurBlitter {
|
|
26
13
|
_packFloat;
|
|
@@ -132,13 +119,12 @@ class BlurBlitter extends GaussianBlurBlitter {
|
|
|
132
119
|
};
|
|
133
120
|
shadowMapParams.implData = implData;
|
|
134
121
|
const colorFormat = this.getShadowMapColorFormat(shadowMapParams);
|
|
135
|
-
const target = shadowMapParams.shadowMapFramebuffer.getColorAttachments()[0].target;
|
|
136
122
|
const shadowMapWidth = shadowMapParams.shadowMapFramebuffer.getColorAttachments()[0].width;
|
|
137
123
|
const shadowMapHeight = shadowMapParams.shadowMapFramebuffer.getColorAttachments()[0].height;
|
|
138
124
|
if (this._blur) {
|
|
139
125
|
shadowMapParams.implData = {
|
|
140
|
-
blurFramebuffer:
|
|
141
|
-
blurFramebuffer2:
|
|
126
|
+
blurFramebuffer: ShadowMapper.fetchTemporalFramebuffer(true, shadowMapParams.lightType, shadowMapParams.numShadowCascades, shadowMapWidth, shadowMapHeight, colorFormat, null, false),
|
|
127
|
+
blurFramebuffer2: ShadowMapper.fetchTemporalFramebuffer(true, shadowMapParams.lightType, shadowMapParams.numShadowCascades, shadowMapWidth, shadowMapHeight, colorFormat, null, true)
|
|
142
128
|
};
|
|
143
129
|
}
|
|
144
130
|
shadowMapParams.shadowMap = this.getShadowMap(shadowMapParams);
|
|
@@ -161,11 +147,7 @@ class BlurBlitter extends GaussianBlurBlitter {
|
|
|
161
147
|
}
|
|
162
148
|
}
|
|
163
149
|
releaseTemporalResources(shadowMapParams) {
|
|
164
|
-
|
|
165
|
-
if (implData) {
|
|
166
|
-
TemporalCache.releaseFramebuffer(implData.blurFramebuffer);
|
|
167
|
-
TemporalCache.releaseFramebuffer(implData.blurFramebuffer2);
|
|
168
|
-
}
|
|
150
|
+
return;
|
|
169
151
|
}
|
|
170
152
|
getDepthScale() {
|
|
171
153
|
return this._depthScale;
|
package/dist/shadow/esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -6,23 +6,8 @@ import { VSM } from './vsm.js';
|
|
|
6
6
|
import { PCFPD } from './pcf_pd.js';
|
|
7
7
|
import { PCFOPT } from './pcf_opt.js';
|
|
8
8
|
import { Application } from '../app.js';
|
|
9
|
-
import '../
|
|
10
|
-
import { LIGHT_TYPE_NONE, LIGHT_TYPE_DIRECTIONAL } from '../values.js';
|
|
11
|
-
import '@zephyr3d/device';
|
|
9
|
+
import { LIGHT_TYPE_NONE, LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_POINT } from '../values.js';
|
|
12
10
|
import { ShaderHelper } from '../material/shader/helper.js';
|
|
13
|
-
import '../material/lambert.js';
|
|
14
|
-
import '../material/blinn.js';
|
|
15
|
-
import '../material/unlit.js';
|
|
16
|
-
import '../material/meshmaterial.js';
|
|
17
|
-
import '../material/grassmaterial.js';
|
|
18
|
-
import '../material/terrainmaterial.js';
|
|
19
|
-
import '../material/pbrmr.js';
|
|
20
|
-
import '../material/pbrsg.js';
|
|
21
|
-
import '../render/renderer.js';
|
|
22
|
-
import '../render/sky.js';
|
|
23
|
-
import '../render/clipmap.js';
|
|
24
|
-
import { TemporalCache } from '../render/temporalcache.js';
|
|
25
|
-
import '../render/watermesh.js';
|
|
26
11
|
|
|
27
12
|
const tmpMatrix = new Matrix4x4();
|
|
28
13
|
const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
@@ -65,8 +50,8 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
65
50
|
shadowMapSize: 1024,
|
|
66
51
|
numCascades: 1,
|
|
67
52
|
splitLambda: 0.5,
|
|
68
|
-
depthBias: 0.
|
|
69
|
-
normalBias: 0.
|
|
53
|
+
depthBias: 0.5,
|
|
54
|
+
normalBias: 0.2,
|
|
70
55
|
nearClip: 1
|
|
71
56
|
};
|
|
72
57
|
this._resourceDirty = true;
|
|
@@ -288,7 +273,7 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
288
273
|
if (ctx.shadowMapInfo) {
|
|
289
274
|
for (const k of ctx.shadowMapInfo.keys()){
|
|
290
275
|
const shadowMapParams = ctx.shadowMapInfo.get(k);
|
|
291
|
-
|
|
276
|
+
ctx.device.pool.releaseFrameBuffer(shadowMapParams.shadowMapFramebuffer);
|
|
292
277
|
shadowMapParams.impl.releaseTemporalResources(shadowMapParams);
|
|
293
278
|
shadowMapParams.lightType = LIGHT_TYPE_NONE;
|
|
294
279
|
shadowMapParams.depthClampEnabled = false;
|
|
@@ -344,6 +329,26 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
344
329
|
return null;
|
|
345
330
|
}
|
|
346
331
|
}
|
|
332
|
+
/** @internal */ static fetchTemporalFramebuffer(autoRelease, lightType, numCascades, width, height, colorFormat, depthFormat, mipmapping) {
|
|
333
|
+
const device = Application.instance.device;
|
|
334
|
+
const useTextureArray = numCascades > 1 && device.type !== 'webgl';
|
|
335
|
+
const colorAttachments = colorFormat ? useTextureArray ? [
|
|
336
|
+
device.pool.fetchTemporalTexture2DArray(false, colorFormat, width, height, numCascades, mipmapping)
|
|
337
|
+
] : lightType === LIGHT_TYPE_POINT ? [
|
|
338
|
+
device.pool.fetchTemporalTextureCube(false, colorFormat, width, mipmapping)
|
|
339
|
+
] : [
|
|
340
|
+
device.pool.fetchTemporalTexture2D(false, colorFormat, width, height, mipmapping)
|
|
341
|
+
] : null;
|
|
342
|
+
const depthAttachment = depthFormat ? useTextureArray ? device.pool.fetchTemporalTexture2DArray(false, depthFormat, width, height, numCascades, false) : device.type !== 'webgl' && lightType === LIGHT_TYPE_POINT ? device.pool.fetchTemporalTextureCube(false, depthFormat, width, false) : device.pool.fetchTemporalTexture2D(false, depthFormat, width, height, false) : null;
|
|
343
|
+
const fb = device.pool.createTemporalFramebuffer(autoRelease, colorAttachments, depthAttachment);
|
|
344
|
+
if (colorAttachments) {
|
|
345
|
+
device.pool.releaseTexture(colorAttachments[0]);
|
|
346
|
+
}
|
|
347
|
+
if (depthAttachment) {
|
|
348
|
+
device.pool.releaseTexture(depthAttachment);
|
|
349
|
+
}
|
|
350
|
+
return fb;
|
|
351
|
+
}
|
|
347
352
|
/** @internal */ updateResources(shadowMapParams) {
|
|
348
353
|
const device = Application.instance.device;
|
|
349
354
|
const colorFormat = shadowMapParams.impl.getShadowMapColorFormat(shadowMapParams);
|
|
@@ -352,9 +357,29 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
352
357
|
const useTextureArray = numCascades > 1 && device.type !== 'webgl';
|
|
353
358
|
const shadowMapWidth = numCascades > 1 && !useTextureArray ? 2 * this._config.shadowMapSize : this._config.shadowMapSize;
|
|
354
359
|
const shadowMapHeight = numCascades > 2 && !useTextureArray ? 2 * this._config.shadowMapSize : this._config.shadowMapSize;
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
360
|
+
/*
|
|
361
|
+
const colorAttachments = colorFormat
|
|
362
|
+
? useTextureArray
|
|
363
|
+
? [device.pool.fetchTemporalTexture2DArray(false, colorFormat, shadowMapWidth, shadowMapHeight, numCascades, false)]
|
|
364
|
+
: this._light.isPointLight()
|
|
365
|
+
? [device.pool.fetchTemporalTextureCube(false, colorFormat, shadowMapWidth, false)]
|
|
366
|
+
: [device.pool.fetchTemporalTexture2D(false, colorFormat, shadowMapWidth, shadowMapHeight, false)]
|
|
367
|
+
: null;
|
|
368
|
+
const depthAttachment = depthFormat
|
|
369
|
+
? useTextureArray
|
|
370
|
+
? device.pool.fetchTemporalTexture2DArray(false, depthFormat, shadowMapWidth, shadowMapHeight, numCascades, false)
|
|
371
|
+
: device.type !== 'webgl' && this._light.isPointLight()
|
|
372
|
+
? device.pool.fetchTemporalTextureCube(false, depthFormat, shadowMapWidth, false)
|
|
373
|
+
: device.pool.fetchTemporalTexture2D(false, depthFormat, shadowMapWidth, shadowMapHeight, false)
|
|
374
|
+
: null;
|
|
375
|
+
shadowMapParams.shadowMapFramebuffer = device.pool.createTemporalFramebuffer(false, colorAttachments, depthAttachment);
|
|
376
|
+
if (colorAttachments) {
|
|
377
|
+
device.pool.releaseTexture(colorAttachments[0]);
|
|
378
|
+
}
|
|
379
|
+
if (depthAttachment) {
|
|
380
|
+
device.pool.releaseTexture(depthAttachment);
|
|
381
|
+
}
|
|
382
|
+
*/ shadowMapParams.shadowMapFramebuffer = ShadowMapper.fetchTemporalFramebuffer(false, this._light.lightType, numCascades, shadowMapWidth, shadowMapHeight, colorFormat, depthFormat);
|
|
358
383
|
shadowMapParams.impl = this._impl;
|
|
359
384
|
this._impl.updateResources(shadowMapParams);
|
|
360
385
|
}
|
|
@@ -410,7 +435,7 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
410
435
|
up.setXYZ(0, 1, 0);
|
|
411
436
|
lightCamera.lookAt(center, target, up);
|
|
412
437
|
lightCamera.position.set(center);
|
|
413
|
-
lightCamera.setOrtho(-radius, radius, -radius, radius, -radius,
|
|
438
|
+
lightCamera.setOrtho(-radius, radius, -radius, radius, -radius, Math.max(Vector3.distance(center, sceneCamera.getWorldPosition()), sceneCamera.getFarPlane()));
|
|
414
439
|
center.setXYZ(0, 0, 0);
|
|
415
440
|
lightCamera.viewProjectionMatrix.transformPointP(center, center);
|
|
416
441
|
if (cropMatrix) {
|
|
@@ -550,11 +575,11 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
550
575
|
}
|
|
551
576
|
return result;
|
|
552
577
|
}
|
|
553
|
-
/** @internal */ calcDepthBiasParams(
|
|
554
|
-
const sizeNear = Math.min(
|
|
555
|
-
const sizeFar = Math.min(
|
|
556
|
-
const scaleFactor = sizeNear / shadowMapSize
|
|
557
|
-
result.setXYZW(depthBias * scaleFactor, normalBias *
|
|
578
|
+
/** @internal */ calcDepthBiasParams(camera, shadowMapSize, depthBias, normalBias, depthScale, result) {
|
|
579
|
+
const sizeNear = Math.min(camera.getProjectionMatrix().getNearPlaneWidth(), camera.getProjectionMatrix().getNearPlaneHeight());
|
|
580
|
+
const sizeFar = Math.min(camera.getProjectionMatrix().getFarPlaneWidth(), camera.getProjectionMatrix().getFarPlaneHeight());
|
|
581
|
+
const scaleFactor = sizeNear / shadowMapSize * 2;
|
|
582
|
+
result.setXYZW(depthBias * scaleFactor, normalBias * 0.0001, depthScale, sizeFar / sizeNear);
|
|
558
583
|
}
|
|
559
584
|
/** @internal */ postRenderShadowMap(shadowMapParams) {
|
|
560
585
|
this._impl.postRenderShadowMap(shadowMapParams);
|
|
@@ -582,7 +607,7 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
582
607
|
if (this._light.isPointLight()) {
|
|
583
608
|
const shadowMapRenderCamera = ShadowMapper.fetchCameraForScene(scene);
|
|
584
609
|
this.createLightCameraPoint(shadowMapRenderCamera);
|
|
585
|
-
this.calcDepthBiasParams(
|
|
610
|
+
this.calcDepthBiasParams(camera, this._config.shadowMapSize, this._config.depthBias, this._config.normalBias, depthScale, shadowMapParams.depthBiasValues[0]);
|
|
586
611
|
shadowMapParams.cameraParams.setXYZW(shadowMapRenderCamera.getNearPlane(), shadowMapRenderCamera.getFarPlane(), this._config.shadowMapSize, this._shadowDistance);
|
|
587
612
|
device.setFramebuffer(fb);
|
|
588
613
|
shadowMapParams.shadowMatrices.set(Matrix4x4.transpose(shadowMapRenderCamera.viewMatrix));
|
|
@@ -617,7 +642,7 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
617
642
|
const border = shadowMapParams.impl.getShadowMapBorder(shadowMapParams); //20 / this._config.shadowMapSize;
|
|
618
643
|
this.createLightCameraDirectional(shadowRegion, cascadeCamera, shadowMapRenderCamera, snapMatrix, border);
|
|
619
644
|
this.createLightCameraDirectional(shadowRegion, cascadeCamera, shadowMapCullCamera, null, border);
|
|
620
|
-
this.calcDepthBiasParams(
|
|
645
|
+
this.calcDepthBiasParams(camera, this._config.shadowMapSize, this._config.depthBias, this._config.normalBias, depthScale, shadowMapParams.depthBiasValues[split]);
|
|
621
646
|
shadowMapParams.depthBiasScales[split] = 1;
|
|
622
647
|
// Incorrect calculation
|
|
623
648
|
// shadowMapParams.depthBiasScales[split] = shadowMapParams.depthBiasValues[0].x !== 0 ? shadowMapParams.depthBiasValues[split].x / shadowMapParams.depthBiasValues[0].x : 1;
|
|
@@ -673,7 +698,7 @@ const tmpFrustum = new Frustum(Matrix4x4.identity());
|
|
|
673
698
|
} else {
|
|
674
699
|
this.createLightCameraSpot(shadowMapRenderCamera);
|
|
675
700
|
}
|
|
676
|
-
this.calcDepthBiasParams(
|
|
701
|
+
this.calcDepthBiasParams(camera, this._config.shadowMapSize, this._config.depthBias, this._config.normalBias, depthScale, shadowMapParams.depthBiasValues[0]);
|
|
677
702
|
shadowMapParams.cameraParams.setXYZW(shadowMapRenderCamera.getNearPlane(), shadowMapRenderCamera.getFarPlane(), this._config.shadowMapSize, this._shadowDistance);
|
|
678
703
|
device.setFramebuffer(fb);
|
|
679
704
|
shadowMapRenderCamera.setProjectionMatrix(Matrix4x4.multiply(snapMatrix, shadowMapRenderCamera.getProjectionMatrix()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadowmapper.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shadowmapper.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/shadow/vsm.js
CHANGED
|
@@ -4,24 +4,8 @@ import { decodeNormalizedFloatFromRGBA, decode2HalfFromRGBA, encode2HalfToRGBA }
|
|
|
4
4
|
import { Application } from '../app.js';
|
|
5
5
|
import { computeShadowMapDepth, filterShadowVSM } from '../shaders/shadow.js';
|
|
6
6
|
import { ShadowMapper } from './shadowmapper.js';
|
|
7
|
-
import '@zephyr3d/base';
|
|
8
|
-
import '../scene/octree.js';
|
|
9
7
|
import { LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT } from '../values.js';
|
|
10
|
-
import '@zephyr3d/device';
|
|
11
8
|
import { ShaderHelper } from '../material/shader/helper.js';
|
|
12
|
-
import '../material/lambert.js';
|
|
13
|
-
import '../material/blinn.js';
|
|
14
|
-
import '../material/unlit.js';
|
|
15
|
-
import '../material/meshmaterial.js';
|
|
16
|
-
import '../material/grassmaterial.js';
|
|
17
|
-
import '../material/terrainmaterial.js';
|
|
18
|
-
import '../material/pbrmr.js';
|
|
19
|
-
import '../material/pbrsg.js';
|
|
20
|
-
import '../render/renderer.js';
|
|
21
|
-
import '../render/sky.js';
|
|
22
|
-
import '../render/clipmap.js';
|
|
23
|
-
import { TemporalCache } from '../render/temporalcache.js';
|
|
24
|
-
import '../render/watermesh.js';
|
|
25
9
|
|
|
26
10
|
class VSMBlitter extends Blitter {
|
|
27
11
|
_phase;
|
|
@@ -191,13 +175,13 @@ class VSMBlitter extends Blitter {
|
|
|
191
175
|
}
|
|
192
176
|
doUpdateResources(shadowMapParams) {
|
|
193
177
|
const colorFormat = this.getShadowMapColorFormat(shadowMapParams);
|
|
194
|
-
const target = shadowMapParams.shadowMapFramebuffer.getColorAttachments()[0].target;
|
|
178
|
+
//const target = shadowMapParams.shadowMapFramebuffer.getColorAttachments()[0].target;
|
|
195
179
|
const shadowMapWidth = shadowMapParams.shadowMapFramebuffer.getColorAttachments()[0].width;
|
|
196
180
|
const shadowMapHeight = shadowMapParams.shadowMapFramebuffer.getColorAttachments()[0].height;
|
|
197
181
|
if (this._blur) {
|
|
198
182
|
shadowMapParams.implData = {
|
|
199
|
-
blurFramebuffer:
|
|
200
|
-
blurFramebuffer2:
|
|
183
|
+
blurFramebuffer: ShadowMapper.fetchTemporalFramebuffer(true, shadowMapParams.lightType, shadowMapParams.numShadowCascades, shadowMapWidth, shadowMapHeight, colorFormat, null, false),
|
|
184
|
+
blurFramebuffer2: ShadowMapper.fetchTemporalFramebuffer(true, shadowMapParams.lightType, shadowMapParams.numShadowCascades, shadowMapWidth, shadowMapHeight, colorFormat, null, this._mipmap)
|
|
201
185
|
};
|
|
202
186
|
}
|
|
203
187
|
shadowMapParams.shadowMap = this.getShadowMap(shadowMapParams);
|
|
@@ -217,11 +201,7 @@ class VSMBlitter extends Blitter {
|
|
|
217
201
|
}
|
|
218
202
|
}
|
|
219
203
|
releaseTemporalResources(shadowMapParams) {
|
|
220
|
-
|
|
221
|
-
if (implData) {
|
|
222
|
-
TemporalCache.releaseFramebuffer(implData.blurFramebuffer);
|
|
223
|
-
TemporalCache.releaseFramebuffer(implData.blurFramebuffer2);
|
|
224
|
-
}
|
|
204
|
+
return;
|
|
225
205
|
}
|
|
226
206
|
getShaderHash() {
|
|
227
207
|
return '';
|
package/dist/shadow/vsm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vsm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vsm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/shapes/cylinder.js
CHANGED
|
@@ -14,11 +14,12 @@ import { Shape } from './shape.js';
|
|
|
14
14
|
}
|
|
15
15
|
/** @internal */ createDefaultOptions() {
|
|
16
16
|
const options = super.createDefaultOptions();
|
|
17
|
-
options.topRadius = 1;
|
|
18
17
|
options.bottomRadius = 1;
|
|
18
|
+
options.topRadius = 1;
|
|
19
19
|
options.heightDetail = 1;
|
|
20
20
|
options.radialDetail = 20;
|
|
21
21
|
options.height = 1;
|
|
22
|
+
options.anchor = 0;
|
|
22
23
|
return options;
|
|
23
24
|
}
|
|
24
25
|
/** @internal */ addPatch(x, y, indices) {
|
|
@@ -30,17 +31,17 @@ import { Shape } from './shape.js';
|
|
|
30
31
|
indices.push(lt, lb, rb, lt, rb, rt);
|
|
31
32
|
}
|
|
32
33
|
/** @internal */ _createArrays(vertices, normals, uvs, indices) {
|
|
33
|
-
const slope = (this._options.
|
|
34
|
+
const slope = (this._options.topRadius - this._options.bottomRadius) / this._options.height;
|
|
34
35
|
for(let y = 0; y <= this._options.heightDetail; y++){
|
|
35
36
|
const v = y / this._options.heightDetail;
|
|
36
|
-
const radius = (this._options.
|
|
37
|
+
const radius = (this._options.topRadius - this._options.bottomRadius) * v + this._options.bottomRadius;
|
|
37
38
|
for(let x = 0; x <= this._options.radialDetail; x++){
|
|
38
39
|
const u = x / this._options.radialDetail;
|
|
39
40
|
const theta = u * Math.PI * 2;
|
|
40
41
|
const sinTheta = Math.sin(theta);
|
|
41
42
|
const cosTheta = Math.cos(theta);
|
|
42
43
|
const m = 1 / Math.sqrt(sinTheta * sinTheta + slope * slope + cosTheta * cosTheta);
|
|
43
|
-
vertices.push(radius * sinTheta, (v -
|
|
44
|
+
vertices.push(radius * sinTheta, (v - this._options.anchor) * this._options.height, radius * cosTheta);
|
|
44
45
|
normals.push(sinTheta * m, slope * m, cosTheta * m);
|
|
45
46
|
uvs.push(u, 1 - v);
|
|
46
47
|
if (y < this._options.heightDetail && x < this._options.radialDetail) {
|
|
@@ -60,7 +61,7 @@ import { Shape } from './shape.js';
|
|
|
60
61
|
this.createAndSetVertexBuffer('normal_f32x3', new Float32Array(normals));
|
|
61
62
|
this.createAndSetVertexBuffer('tex0_f32x2', new Float32Array(uvs));
|
|
62
63
|
this.createAndSetIndexBuffer(new Uint16Array(indices));
|
|
63
|
-
const radiusMax = Math.max(this._options.
|
|
64
|
+
const radiusMax = Math.max(this._options.bottomRadius, this._options.topRadius);
|
|
64
65
|
this.setBoundingVolume(new BoundingBox(new Vector3(-radiusMax, 0, -radiusMax), new Vector3(radiusMax, this._options.height, radiusMax)));
|
|
65
66
|
this.indexCount = indices.length;
|
|
66
67
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cylinder.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cylinder.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AABB, Frustum, ClipState } from '@zephyr3d/base';
|
|
2
|
-
import { AABBTree } from './aabbtree.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* The bounding box class
|
|
@@ -25,57 +24,6 @@ import { AABBTree } from './aabbtree.js';
|
|
|
25
24
|
return this;
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Bounding box tree
|
|
30
|
-
* @public
|
|
31
|
-
*/ class BoundingBoxTree extends AABBTree {
|
|
32
|
-
constructor(arg){
|
|
33
|
-
super(arg);
|
|
34
|
-
}
|
|
35
|
-
/** {@inheritDoc BoundingVolume.clone} */ clone() {
|
|
36
|
-
return new BoundingBoxTree(this);
|
|
37
|
-
}
|
|
38
|
-
/** {@inheritDoc BoundingVolume.transform} */ transform(matrix) {
|
|
39
|
-
const newBV = new BoundingBoxTree(this);
|
|
40
|
-
newBV.transform(matrix);
|
|
41
|
-
return newBV;
|
|
42
|
-
}
|
|
43
|
-
/** {@inheritDoc BoundingVolume.behindPlane} */ behindPlane(plane) {
|
|
44
|
-
return this.toAABB().behindPlane(plane);
|
|
45
|
-
}
|
|
46
|
-
/** {@inheritDoc BoundingVolume.outsideFrustum} */ outsideFrustum(frustum) {
|
|
47
|
-
const aabb = this.getTopLevelAABB();
|
|
48
|
-
if (aabb) {
|
|
49
|
-
return (frustum instanceof Frustum ? aabb.getClipStateWithFrustum(frustum) : aabb.getClipState(frustum)) === ClipState.NOT_CLIPPED;
|
|
50
|
-
} else {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/** {@inheritDoc BoundingVolume.toAABB} */ toAABB() {
|
|
55
|
-
return this.getTopLevelAABB();
|
|
56
|
-
}
|
|
57
|
-
} /*
|
|
58
|
-
export class BoundingFrustum implements BoundingVolume {
|
|
59
|
-
protected _frustum: Frustum;
|
|
60
|
-
constructor ();
|
|
61
|
-
constructor (other: BoundingFrustum|Frustum|Matrix4x4);
|
|
62
|
-
constructor (arg0?: BoundingFrustum|Frustum|Matrix4x4) {
|
|
63
|
-
if (arg0 instanceof BoundingFrustum) {
|
|
64
|
-
this._frustum = arg0._frustum ? new Frustum (arg0._frustum) : null;
|
|
65
|
-
} else if (arg0 instanceof Frustum) {
|
|
66
|
-
this._frustum = new Frustum (arg0);
|
|
67
|
-
} else if (arg0 instanceof Matrix4x4) {
|
|
68
|
-
this._frustum = new Frustum (arg0);
|
|
69
|
-
} else {
|
|
70
|
-
this._frustum = null;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
clone (): BoundingVolume {
|
|
74
|
-
return new BoundingFrustum (this);
|
|
75
|
-
}
|
|
76
|
-
transform (matrix: Matrix4x4)
|
|
77
|
-
}
|
|
78
|
-
*/
|
|
79
27
|
|
|
80
|
-
export { BoundingBox
|
|
28
|
+
export { BoundingBox };
|
|
81
29
|
//# sourceMappingURL=bounding_volume.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounding_volume.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bounding_volume.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
class DracoMeshDecoder {
|
|
2
|
+
_module;
|
|
3
|
+
_decoder;
|
|
4
|
+
_mesh;
|
|
5
|
+
constructor(data, decoderModule){
|
|
6
|
+
this._module = decoderModule;
|
|
7
|
+
this._decoder = new this._module.Decoder();
|
|
8
|
+
const buffer = new this._module.DecoderBuffer();
|
|
9
|
+
buffer.Init(data, data.byteLength);
|
|
10
|
+
const geometryType = this._decoder.GetEncodedGeometryType(buffer);
|
|
11
|
+
if (geometryType !== this._module.TRIANGULAR_MESH) {
|
|
12
|
+
this._module.destroy(buffer);
|
|
13
|
+
this._module.destroy(this._decoder);
|
|
14
|
+
this._decoder = null;
|
|
15
|
+
throw new Error(`Unsupported geometry type: ${geometryType}`);
|
|
16
|
+
}
|
|
17
|
+
this._mesh = new this._module.Mesh();
|
|
18
|
+
const status = this._decoder.DecodeBufferToMesh(buffer, this._mesh);
|
|
19
|
+
this._module.destroy(buffer);
|
|
20
|
+
if (!status.ok() || this._mesh.ptr === 0) {
|
|
21
|
+
this._module.destroy(this._decoder);
|
|
22
|
+
this._decoder = null;
|
|
23
|
+
this._module.destroy(this._mesh);
|
|
24
|
+
this._mesh = null;
|
|
25
|
+
throw new Error(status.error_msg());
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
getIndexBuffer() {
|
|
29
|
+
if (!this._decoder || !this._mesh) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const numFaces = this._mesh.num_faces();
|
|
33
|
+
const numIndices = numFaces * 3;
|
|
34
|
+
// Uint32
|
|
35
|
+
const indexBuffer = new Uint32Array(numIndices);
|
|
36
|
+
const ptr = this._module._malloc(indexBuffer.byteLength);
|
|
37
|
+
this._decoder.GetTrianglesUInt32Array(this._mesh, indexBuffer.byteLength, ptr);
|
|
38
|
+
const tmpBuffer = new Uint32Array(this._module.HEAPU32.buffer, ptr, numIndices);
|
|
39
|
+
indexBuffer.set(tmpBuffer);
|
|
40
|
+
this._module._free(ptr);
|
|
41
|
+
return indexBuffer;
|
|
42
|
+
}
|
|
43
|
+
getAttributeBuffer(id, buffer) {
|
|
44
|
+
if (!this._decoder || !this._mesh) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const attribute = this._decoder.GetAttributeByUniqueId(this._mesh, id);
|
|
48
|
+
if (!attribute) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const numComponents = attribute.num_components();
|
|
52
|
+
const numPoints = this._mesh.num_points();
|
|
53
|
+
const numValues = numPoints * numComponents;
|
|
54
|
+
if (buffer.length !== numValues) {
|
|
55
|
+
console.error(`getAttributeBuffer(): buffer length must be ${numValues}`);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const ptr = this._module._malloc(buffer.byteLength);
|
|
59
|
+
this._decoder.GetAttributeDataArrayForAllPoints(this._mesh, attribute, this.getDracoDataType(buffer), buffer.byteLength, ptr);
|
|
60
|
+
const tmpBuffer = new buffer.constructor(this.getDracoHeap(buffer).buffer, ptr, numValues);
|
|
61
|
+
buffer.set(tmpBuffer);
|
|
62
|
+
this._module._free(ptr);
|
|
63
|
+
return buffer;
|
|
64
|
+
}
|
|
65
|
+
getDracoDataType(buffer) {
|
|
66
|
+
if (buffer instanceof Float32Array) {
|
|
67
|
+
return this._module.DT_FLOAT32;
|
|
68
|
+
}
|
|
69
|
+
if (buffer instanceof Int8Array) {
|
|
70
|
+
return this._module.DT_INT8;
|
|
71
|
+
}
|
|
72
|
+
if (buffer instanceof Int16Array) {
|
|
73
|
+
return this._module.DT_INT16;
|
|
74
|
+
}
|
|
75
|
+
if (buffer instanceof Int32Array) {
|
|
76
|
+
return this._module.DT_INT32;
|
|
77
|
+
}
|
|
78
|
+
if (buffer instanceof Uint8Array) {
|
|
79
|
+
return this._module.DT_UINT8;
|
|
80
|
+
}
|
|
81
|
+
if (buffer instanceof Uint16Array) {
|
|
82
|
+
return this._module.DT_UINT16;
|
|
83
|
+
}
|
|
84
|
+
if (buffer instanceof Uint32Array) {
|
|
85
|
+
return this._module.DT_UINT32;
|
|
86
|
+
}
|
|
87
|
+
throw new Error(`getDracoDataType(): invalid buffer type`);
|
|
88
|
+
}
|
|
89
|
+
getDracoHeap(buffer) {
|
|
90
|
+
if (buffer instanceof Float32Array) {
|
|
91
|
+
return this._module.HEAPF32;
|
|
92
|
+
}
|
|
93
|
+
if (buffer instanceof Int8Array) {
|
|
94
|
+
return this._module.HEAP8;
|
|
95
|
+
}
|
|
96
|
+
if (buffer instanceof Int16Array) {
|
|
97
|
+
return this._module.HEAP16;
|
|
98
|
+
}
|
|
99
|
+
if (buffer instanceof Int32Array) {
|
|
100
|
+
return this._module.HEAP32;
|
|
101
|
+
}
|
|
102
|
+
if (buffer instanceof Uint8Array) {
|
|
103
|
+
return this._module.HEAPU8;
|
|
104
|
+
}
|
|
105
|
+
if (buffer instanceof Uint16Array) {
|
|
106
|
+
return this._module.HEAPU16;
|
|
107
|
+
}
|
|
108
|
+
if (buffer instanceof Uint32Array) {
|
|
109
|
+
return this._module.HEAPU32;
|
|
110
|
+
}
|
|
111
|
+
throw new Error(`getDracoHeap(): invalid buffer type`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { DracoMeshDecoder };
|
|
116
|
+
//# sourceMappingURL=decoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decoder.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Application } from '../app.js';
|
|
2
|
+
import '@zephyr3d/base';
|
|
3
|
+
import '@zephyr3d/device';
|
|
4
|
+
import { CopyBlitter } from '../blitter/copy.js';
|
|
5
|
+
|
|
6
|
+
const samplerOptions = {
|
|
7
|
+
clamp_linear: {
|
|
8
|
+
addressU: 'clamp',
|
|
9
|
+
addressV: 'clamp',
|
|
10
|
+
magFilter: 'linear',
|
|
11
|
+
minFilter: 'linear',
|
|
12
|
+
mipFilter: 'linear'
|
|
13
|
+
},
|
|
14
|
+
clamp_linear_nomip: {
|
|
15
|
+
addressU: 'clamp',
|
|
16
|
+
addressV: 'clamp',
|
|
17
|
+
magFilter: 'linear',
|
|
18
|
+
minFilter: 'linear',
|
|
19
|
+
mipFilter: 'none'
|
|
20
|
+
},
|
|
21
|
+
clamp_nearest: {
|
|
22
|
+
addressU: 'clamp',
|
|
23
|
+
addressV: 'clamp',
|
|
24
|
+
magFilter: 'nearest',
|
|
25
|
+
minFilter: 'nearest',
|
|
26
|
+
mipFilter: 'nearest'
|
|
27
|
+
},
|
|
28
|
+
clamp_nearest_nomip: {
|
|
29
|
+
addressU: 'clamp',
|
|
30
|
+
addressV: 'clamp',
|
|
31
|
+
magFilter: 'nearest',
|
|
32
|
+
minFilter: 'nearest',
|
|
33
|
+
mipFilter: 'none'
|
|
34
|
+
},
|
|
35
|
+
repeat_linear: {
|
|
36
|
+
addressU: 'repeat',
|
|
37
|
+
addressV: 'repeat',
|
|
38
|
+
magFilter: 'linear',
|
|
39
|
+
minFilter: 'linear',
|
|
40
|
+
mipFilter: 'linear'
|
|
41
|
+
},
|
|
42
|
+
repeat_linear_nomip: {
|
|
43
|
+
addressU: 'repeat',
|
|
44
|
+
addressV: 'repeat',
|
|
45
|
+
magFilter: 'linear',
|
|
46
|
+
minFilter: 'linear',
|
|
47
|
+
mipFilter: 'none'
|
|
48
|
+
},
|
|
49
|
+
repeat_nearest: {
|
|
50
|
+
addressU: 'repeat',
|
|
51
|
+
addressV: 'repeat',
|
|
52
|
+
magFilter: 'nearest',
|
|
53
|
+
minFilter: 'nearest',
|
|
54
|
+
mipFilter: 'nearest'
|
|
55
|
+
},
|
|
56
|
+
repeat_nearest_nomip: {
|
|
57
|
+
addressU: 'repeat',
|
|
58
|
+
addressV: 'repeat',
|
|
59
|
+
magFilter: 'nearest',
|
|
60
|
+
minFilter: 'nearest',
|
|
61
|
+
mipFilter: 'none'
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const samplers = {};
|
|
65
|
+
let copyBlitter = null;
|
|
66
|
+
let defaultCopyRenderState = null;
|
|
67
|
+
function fetchSampler(type) {
|
|
68
|
+
let sampler = samplers[type];
|
|
69
|
+
if (!sampler) {
|
|
70
|
+
const opt = samplerOptions[type];
|
|
71
|
+
if (opt) {
|
|
72
|
+
sampler = Application.instance.device.createSampler(opt);
|
|
73
|
+
samplers[type] = sampler;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return sampler;
|
|
77
|
+
}
|
|
78
|
+
function copyTexture(src, dest, sampler = null, renderState = null, layer = 0, srgbOut = false) {
|
|
79
|
+
if (!renderState && !defaultCopyRenderState) {
|
|
80
|
+
defaultCopyRenderState = src.device.createRenderStateSet();
|
|
81
|
+
defaultCopyRenderState.useDepthState().enableTest(false).enableWrite(false);
|
|
82
|
+
defaultCopyRenderState.useRasterizerState().setCullMode('none');
|
|
83
|
+
}
|
|
84
|
+
if (!copyBlitter) {
|
|
85
|
+
copyBlitter = new CopyBlitter();
|
|
86
|
+
}
|
|
87
|
+
copyBlitter.renderStates = renderState ?? defaultCopyRenderState;
|
|
88
|
+
copyBlitter.srgbOut = srgbOut;
|
|
89
|
+
copyBlitter.blit(src, dest, layer, sampler);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { copyTexture, fetchSampler };
|
|
93
|
+
//# sourceMappingURL=misc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,6 +3,7 @@ import { Application } from '../app.js';
|
|
|
3
3
|
import { Blitter } from '../blitter/blitter.js';
|
|
4
4
|
import '@zephyr3d/device';
|
|
5
5
|
import { CopyBlitter } from '../blitter/copy.js';
|
|
6
|
+
import { fetchSampler } from './misc.js';
|
|
6
7
|
|
|
7
8
|
class ReduceBlitter extends Blitter {
|
|
8
9
|
_width;
|
|
@@ -277,13 +278,7 @@ async function doProjectCubemap(srcTexture, coeff) {
|
|
|
277
278
|
device.setFramebuffer(null);
|
|
278
279
|
framebuffer.dispose();
|
|
279
280
|
const blitter = new ReduceBlitter();
|
|
280
|
-
const sampler =
|
|
281
|
-
addressU: 'clamp',
|
|
282
|
-
addressV: 'clamp',
|
|
283
|
-
magFilter: 'nearest',
|
|
284
|
-
minFilter: 'nearest',
|
|
285
|
-
mipFilter: 'none'
|
|
286
|
-
});
|
|
281
|
+
const sampler = fetchSampler('clamp_nearest_nomip');
|
|
287
282
|
for(let i = 1; i < tmpTextures.length; i++){
|
|
288
283
|
blitter.width = tmpTextures[i - 1].width;
|
|
289
284
|
blitter.blit(tmpTextures[i - 1], tmpTextures[i], sampler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shprojection.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shprojection.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|