@zephyr3d/scene 0.1.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 +173 -0
- package/dist/animation/animation.js.map +1 -0
- package/dist/animation/animationset.js +95 -0
- package/dist/animation/animationset.js.map +1 -0
- package/dist/animation/animationtrack.js +38 -0
- package/dist/animation/animationtrack.js.map +1 -0
- package/dist/animation/eulerrotationtrack.js +33 -0
- package/dist/animation/eulerrotationtrack.js.map +1 -0
- package/dist/animation/rotationtrack.js +37 -0
- package/dist/animation/rotationtrack.js.map +1 -0
- package/dist/animation/scaletrack.js +36 -0
- package/dist/animation/scaletrack.js.map +1 -0
- package/dist/animation/skeleton.js +97 -0
- package/dist/animation/skeleton.js.map +1 -0
- package/dist/animation/translationtrack.js +36 -0
- package/dist/animation/translationtrack.js.map +1 -0
- package/dist/animation/usertrack.js +47 -0
- package/dist/animation/usertrack.js.map +1 -0
- package/dist/app.js +173 -0
- package/dist/app.js.map +1 -0
- package/dist/asset/assetmanager.js +476 -0
- package/dist/asset/assetmanager.js.map +1 -0
- package/dist/asset/builtin.js +373 -0
- package/dist/asset/builtin.js.map +1 -0
- package/dist/asset/loaders/dds/dds.js +472 -0
- package/dist/asset/loaders/dds/dds.js.map +1 -0
- package/dist/asset/loaders/dds/dds_loader.js +38 -0
- package/dist/asset/loaders/dds/dds_loader.js.map +1 -0
- package/dist/asset/loaders/gltf/gltf_loader.js +981 -0
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -0
- package/dist/asset/loaders/gltf/helpers.js +314 -0
- package/dist/asset/loaders/gltf/helpers.js.map +1 -0
- package/dist/asset/loaders/hdr/hdr.js +175 -0
- package/dist/asset/loaders/hdr/hdr.js.map +1 -0
- package/dist/asset/loaders/image/tga_Loader.js +117 -0
- package/dist/asset/loaders/image/tga_Loader.js.map +1 -0
- package/dist/asset/loaders/image/webimage_loader.js +50 -0
- package/dist/asset/loaders/image/webimage_loader.js.map +1 -0
- package/dist/asset/loaders/loader.js +45 -0
- package/dist/asset/loaders/loader.js.map +1 -0
- package/dist/asset/model.js +264 -0
- package/dist/asset/model.js.map +1 -0
- package/dist/blitter/blitter.js +389 -0
- package/dist/blitter/blitter.js.map +1 -0
- package/dist/blitter/box.js +118 -0
- package/dist/blitter/box.js.map +1 -0
- package/dist/blitter/copy.js +22 -0
- package/dist/blitter/copy.js.map +1 -0
- package/dist/blitter/depthlimitedgaussion.js +166 -0
- package/dist/blitter/depthlimitedgaussion.js.map +1 -0
- package/dist/blitter/gaussianblur.js +229 -0
- package/dist/blitter/gaussianblur.js.map +1 -0
- package/dist/camera/base.js +90 -0
- package/dist/camera/base.js.map +1 -0
- package/dist/camera/camera.js +358 -0
- package/dist/camera/camera.js.map +1 -0
- package/dist/camera/fps.js +246 -0
- package/dist/camera/fps.js.map +1 -0
- package/dist/camera/orbit.js +157 -0
- package/dist/camera/orbit.js.map +1 -0
- package/dist/camera/orthocamera.js +126 -0
- package/dist/camera/orthocamera.js.map +1 -0
- package/dist/camera/perspectivecamera.js +133 -0
- package/dist/camera/perspectivecamera.js.map +1 -0
- package/dist/index.d.ts +8402 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/input/inputmgr.js +242 -0
- package/dist/input/inputmgr.js.map +1 -0
- package/dist/material/blinn.js +75 -0
- package/dist/material/blinn.js.map +1 -0
- package/dist/material/grassmaterial.js +221 -0
- package/dist/material/grassmaterial.js.map +1 -0
- package/dist/material/lambert.js +52 -0
- package/dist/material/lambert.js.map +1 -0
- package/dist/material/lightmodel.js +2074 -0
- package/dist/material/lightmodel.js.map +1 -0
- package/dist/material/lit.js +578 -0
- package/dist/material/lit.js.map +1 -0
- package/dist/material/material.js +458 -0
- package/dist/material/material.js.map +1 -0
- package/dist/material/meshmaterial.js +311 -0
- package/dist/material/meshmaterial.js.map +1 -0
- package/dist/material/mixins/albedocolor.js +130 -0
- package/dist/material/mixins/albedocolor.js.map +1 -0
- package/dist/material/mixins/texture.js +110 -0
- package/dist/material/mixins/texture.js.map +1 -0
- package/dist/material/mixins/vertexcolor.js +45 -0
- package/dist/material/mixins/vertexcolor.js.map +1 -0
- package/dist/material/pbr.js +27 -0
- package/dist/material/pbr.js.map +1 -0
- package/dist/material/standard.js +282 -0
- package/dist/material/standard.js.map +1 -0
- package/dist/material/terrainlightmodel.js +259 -0
- package/dist/material/terrainlightmodel.js.map +1 -0
- package/dist/material/terrainmaterial.js +139 -0
- package/dist/material/terrainmaterial.js.map +1 -0
- package/dist/material/unlit.js +29 -0
- package/dist/material/unlit.js.map +1 -0
- package/dist/posteffect/bloom.js +398 -0
- package/dist/posteffect/bloom.js.map +1 -0
- package/dist/posteffect/compositor.js +264 -0
- package/dist/posteffect/compositor.js.map +1 -0
- package/dist/posteffect/fxaa.js +291 -0
- package/dist/posteffect/fxaa.js.map +1 -0
- package/dist/posteffect/grayscale.js +87 -0
- package/dist/posteffect/grayscale.js.map +1 -0
- package/dist/posteffect/posteffect.js +165 -0
- package/dist/posteffect/posteffect.js.map +1 -0
- package/dist/posteffect/sao.js +327 -0
- package/dist/posteffect/sao.js.map +1 -0
- package/dist/posteffect/tonemap.js +112 -0
- package/dist/posteffect/tonemap.js.map +1 -0
- package/dist/posteffect/water.js +535 -0
- package/dist/posteffect/water.js.map +1 -0
- package/dist/render/clipmap.js +462 -0
- package/dist/render/clipmap.js.map +1 -0
- package/dist/render/cluster_light.js +329 -0
- package/dist/render/cluster_light.js.map +1 -0
- package/dist/render/cull_visitor.js +124 -0
- package/dist/render/cull_visitor.js.map +1 -0
- package/dist/render/depth_pass.js +47 -0
- package/dist/render/depth_pass.js.map +1 -0
- package/dist/render/envlight.js +282 -0
- package/dist/render/envlight.js.map +1 -0
- package/dist/render/forward.js +186 -0
- package/dist/render/forward.js.map +1 -0
- package/dist/render/forward_pass.js +137 -0
- package/dist/render/forward_pass.js.map +1 -0
- package/dist/render/helper.js +38 -0
- package/dist/render/helper.js.map +1 -0
- package/dist/render/primitive.js +246 -0
- package/dist/render/primitive.js.map +1 -0
- package/dist/render/render_queue.js +163 -0
- package/dist/render/render_queue.js.map +1 -0
- package/dist/render/renderpass.js +151 -0
- package/dist/render/renderpass.js.map +1 -0
- package/dist/render/renderscheme.js +61 -0
- package/dist/render/renderscheme.js.map +1 -0
- package/dist/render/scatteringlut.js +634 -0
- package/dist/render/scatteringlut.js.map +1 -0
- package/dist/render/shadowmap_pass.js +70 -0
- package/dist/render/shadowmap_pass.js.map +1 -0
- package/dist/render/sky.js +881 -0
- package/dist/render/sky.js.map +1 -0
- package/dist/render/temporalcache.js +222 -0
- package/dist/render/temporalcache.js.map +1 -0
- package/dist/render/watermesh.js +835 -0
- package/dist/render/watermesh.js.map +1 -0
- package/dist/scene/environment.js +146 -0
- package/dist/scene/environment.js.map +1 -0
- package/dist/scene/graph_node.js +69 -0
- package/dist/scene/graph_node.js.map +1 -0
- package/dist/scene/light.js +436 -0
- package/dist/scene/light.js.map +1 -0
- package/dist/scene/mesh.js +215 -0
- package/dist/scene/mesh.js.map +1 -0
- package/dist/scene/model.js +111 -0
- package/dist/scene/model.js.map +1 -0
- package/dist/scene/octree.js +651 -0
- package/dist/scene/octree.js.map +1 -0
- package/dist/scene/octree_update_visitor.js +16 -0
- package/dist/scene/octree_update_visitor.js.map +1 -0
- package/dist/scene/raycast_visitor.js +72 -0
- package/dist/scene/raycast_visitor.js.map +1 -0
- package/dist/scene/scene.js +225 -0
- package/dist/scene/scene.js.map +1 -0
- package/dist/scene/scene_node.js +299 -0
- package/dist/scene/scene_node.js.map +1 -0
- package/dist/scene/terrain/grass.js +277 -0
- package/dist/scene/terrain/grass.js.map +1 -0
- package/dist/scene/terrain/heightfield.js +391 -0
- package/dist/scene/terrain/heightfield.js.map +1 -0
- package/dist/scene/terrain/patch.js +530 -0
- package/dist/scene/terrain/patch.js.map +1 -0
- package/dist/scene/terrain/quadtree.js +430 -0
- package/dist/scene/terrain/quadtree.js.map +1 -0
- package/dist/scene/terrain/terrain.js +258 -0
- package/dist/scene/terrain/terrain.js.map +1 -0
- package/dist/scene/xform.js +224 -0
- package/dist/scene/xform.js.map +1 -0
- package/dist/shaders/builtins.js +110 -0
- package/dist/shaders/builtins.js.map +1 -0
- package/dist/shaders/framework.js +709 -0
- package/dist/shaders/framework.js.map +1 -0
- package/dist/shaders/lighting.js +335 -0
- package/dist/shaders/lighting.js.map +1 -0
- package/dist/shaders/misc.js +405 -0
- package/dist/shaders/misc.js.map +1 -0
- package/dist/shaders/noise.js +157 -0
- package/dist/shaders/noise.js.map +1 -0
- package/dist/shaders/pbr.js +132 -0
- package/dist/shaders/pbr.js.map +1 -0
- package/dist/shaders/shadow.js +642 -0
- package/dist/shaders/shadow.js.map +1 -0
- package/dist/shaders/water.js +630 -0
- package/dist/shaders/water.js.map +1 -0
- package/dist/shadow/esm.js +235 -0
- package/dist/shadow/esm.js.map +1 -0
- package/dist/shadow/pcf_opt.js +182 -0
- package/dist/shadow/pcf_opt.js.map +1 -0
- package/dist/shadow/pcf_pd.js +190 -0
- package/dist/shadow/pcf_pd.js.map +1 -0
- package/dist/shadow/shadow_impl.js +15 -0
- package/dist/shadow/shadow_impl.js.map +1 -0
- package/dist/shadow/shadowmapper.js +709 -0
- package/dist/shadow/shadowmapper.js.map +1 -0
- package/dist/shadow/ssm.js +194 -0
- package/dist/shadow/ssm.js.map +1 -0
- package/dist/shadow/vsm.js +298 -0
- package/dist/shadow/vsm.js.map +1 -0
- package/dist/shapes/box.js +313 -0
- package/dist/shapes/box.js.map +1 -0
- package/dist/shapes/cylinder.js +74 -0
- package/dist/shapes/cylinder.js.map +1 -0
- package/dist/shapes/plane.js +48 -0
- package/dist/shapes/plane.js.map +1 -0
- package/dist/shapes/shape.js +33 -0
- package/dist/shapes/shape.js.map +1 -0
- package/dist/shapes/sphere.js +91 -0
- package/dist/shapes/sphere.js.map +1 -0
- package/dist/shapes/torus.js +100 -0
- package/dist/shapes/torus.js.map +1 -0
- package/dist/utility/aabbtree.js +390 -0
- package/dist/utility/aabbtree.js.map +1 -0
- package/dist/utility/bounding_volume.js +78 -0
- package/dist/utility/bounding_volume.js.map +1 -0
- package/dist/utility/panorama.js +163 -0
- package/dist/utility/panorama.js.map +1 -0
- package/dist/utility/pmrem.js +345 -0
- package/dist/utility/pmrem.js.map +1 -0
- package/dist/utility/shprojection.js +448 -0
- package/dist/utility/shprojection.js.map +1 -0
- package/dist/values.js +48 -0
- package/dist/values.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sky.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { Application } from '../app.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Temporal framebuffer cache
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/ class TemporalCache {
|
|
8
|
+
static _ownDepthTextures = new Set();
|
|
9
|
+
static _variantWidth = 0;
|
|
10
|
+
static _variantHeight = 0;
|
|
11
|
+
static _releaseFuncs = new Map();
|
|
12
|
+
static _cachedFrameBuffers = {};
|
|
13
|
+
static getFramebufferFixedSize(width, height, numLayers, colorFmt, depthFmt, colorType, depthType, mipmapping, sampleCount = 1) {
|
|
14
|
+
return this.getFramebuffer(width, height, numLayers, colorFmt, depthFmt, colorType, depthType, mipmapping, false, sampleCount);
|
|
15
|
+
}
|
|
16
|
+
static getFramebufferVariantSize(width, height, numLayers, colorFmt, depthFmt, colorType, depthType, mipmapping, sampleCount = 1) {
|
|
17
|
+
return this.getFramebuffer(width, height, numLayers, colorFmt, depthFmt, colorType, depthType, mipmapping, true, sampleCount);
|
|
18
|
+
}
|
|
19
|
+
static getFramebufferFixedSizeWithDepth(depthTex, numLayers, colorFmt, colorType, mipmapping, sampleCount = 1) {
|
|
20
|
+
return this.getFramebufferWithDepth(depthTex, numLayers, colorFmt, colorType, mipmapping, false, sampleCount);
|
|
21
|
+
}
|
|
22
|
+
static getFramebufferVariantSizeWithDepth(depthTex, numLayers, colorFmt, colorType, mipmapping, sampleCount = 1) {
|
|
23
|
+
return this.getFramebufferWithDepth(depthTex, numLayers, colorFmt, colorType, mipmapping, true, sampleCount);
|
|
24
|
+
}
|
|
25
|
+
static getFramebuffer(width, height, numLayers, colorFmt, depthFmt, colorType, depthType, mipmapping, variant, sampleCount) {
|
|
26
|
+
if (variant && (width !== this._variantWidth || height !== this._variantHeight)) {
|
|
27
|
+
this.purgeVariantFramebuffers();
|
|
28
|
+
this._variantWidth = width;
|
|
29
|
+
this._variantHeight = height;
|
|
30
|
+
}
|
|
31
|
+
if (colorType !== '2darray' && depthType !== '2darray') {
|
|
32
|
+
numLayers = 1;
|
|
33
|
+
}
|
|
34
|
+
const device = Application.instance.device;
|
|
35
|
+
if (device.type === 'webgl') {
|
|
36
|
+
sampleCount = 1;
|
|
37
|
+
}
|
|
38
|
+
const sizeHash = variant ? '' : `${width}x${height}`;
|
|
39
|
+
const fmtHash = `${colorFmt ?? ''}:${depthFmt ?? ''}:${colorFmt ? colorType : ''}:${numLayers}:${depthFmt ? depthType : ''}:${colorFmt && mipmapping ? 1 : 0}:${sampleCount}`;
|
|
40
|
+
const sizedFrameBuffers = this._cachedFrameBuffers[sizeHash];
|
|
41
|
+
const fbList = sizedFrameBuffers?.get(null)?.[fmtHash];
|
|
42
|
+
let fb = null;
|
|
43
|
+
if (!fbList || fbList.length === 0) {
|
|
44
|
+
let colorTex = null;
|
|
45
|
+
const opt = mipmapping ? {} : {
|
|
46
|
+
samplerOptions: {
|
|
47
|
+
mipFilter: 'none'
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
if (colorFmt) {
|
|
51
|
+
switch(colorType){
|
|
52
|
+
case '2d':
|
|
53
|
+
colorTex = device.createTexture2D(colorFmt, width, height, opt);
|
|
54
|
+
break;
|
|
55
|
+
case '2darray':
|
|
56
|
+
colorTex = device.createTexture2DArray(colorFmt, width, height, numLayers, opt);
|
|
57
|
+
break;
|
|
58
|
+
case 'cube':
|
|
59
|
+
colorTex = device.createCubeTexture(colorFmt, width, opt);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
let depthTex = null;
|
|
64
|
+
if (depthFmt) {
|
|
65
|
+
switch(depthType){
|
|
66
|
+
case '2d':
|
|
67
|
+
depthTex = device.createTexture2D(depthFmt, width, height);
|
|
68
|
+
break;
|
|
69
|
+
case '2darray':
|
|
70
|
+
depthTex = device.createTexture2DArray(depthFmt, width, height, numLayers);
|
|
71
|
+
break;
|
|
72
|
+
case 'cube':
|
|
73
|
+
depthTex = device.createCubeTexture(depthFmt, width);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
fb = device.createFrameBuffer(colorTex ? [
|
|
78
|
+
colorTex
|
|
79
|
+
] : [], depthTex, {
|
|
80
|
+
sampleCount,
|
|
81
|
+
ignoreDepthStencil: false
|
|
82
|
+
});
|
|
83
|
+
this._ownDepthTextures.add(depthTex);
|
|
84
|
+
} else {
|
|
85
|
+
fb = fbList.pop();
|
|
86
|
+
}
|
|
87
|
+
this._releaseFuncs.set(fb, variant ? this.releaseWithoutDepthTexVariantSize : this.releaseWithoutDepthTexFixedSize);
|
|
88
|
+
return fb;
|
|
89
|
+
}
|
|
90
|
+
static getFramebufferWithDepth(depth, numLayers, colorFmt, colorType, mipmapping, variant, sampleCount) {
|
|
91
|
+
if (variant && (depth.width !== this._variantWidth || depth.height !== this._variantHeight)) {
|
|
92
|
+
this.purgeVariantFramebuffers();
|
|
93
|
+
this._variantWidth = depth.width;
|
|
94
|
+
this._variantHeight = depth.height;
|
|
95
|
+
}
|
|
96
|
+
if (!colorFmt || colorType !== '2darray') {
|
|
97
|
+
numLayers = 1;
|
|
98
|
+
}
|
|
99
|
+
const device = Application.instance.device;
|
|
100
|
+
if (device.type === 'webgl') {
|
|
101
|
+
sampleCount = 1;
|
|
102
|
+
}
|
|
103
|
+
const sizeHash = variant ? '' : `${depth.width}x${depth.height}`;
|
|
104
|
+
const fmtHash = `${colorFmt ?? ''}:${depth.format}:${colorFmt ? colorType : ''}:${numLayers}:${depth.target}:${colorFmt && mipmapping ? 1 : 0}:${sampleCount}`;
|
|
105
|
+
const sizedFrameBuffers = this._cachedFrameBuffers[sizeHash];
|
|
106
|
+
const fbList = sizedFrameBuffers?.get(depth)?.[fmtHash];
|
|
107
|
+
let fb = null;
|
|
108
|
+
if (!fbList || fbList.length === 0) {
|
|
109
|
+
let colorTex = null;
|
|
110
|
+
const opt = mipmapping ? {} : {
|
|
111
|
+
samplerOptions: {
|
|
112
|
+
mipFilter: 'none'
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
if (colorFmt) {
|
|
116
|
+
switch(colorType){
|
|
117
|
+
case '2d':
|
|
118
|
+
colorTex = device.createTexture2D(colorFmt, depth.width, depth.height, opt);
|
|
119
|
+
break;
|
|
120
|
+
case '2darray':
|
|
121
|
+
colorTex = device.createTexture2DArray(colorFmt, depth.width, depth.height, numLayers, opt);
|
|
122
|
+
break;
|
|
123
|
+
case 'cube':
|
|
124
|
+
colorTex = device.createCubeTexture(colorFmt, depth.width, opt);
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
fb = device.createFrameBuffer([
|
|
129
|
+
colorTex
|
|
130
|
+
], depth, {
|
|
131
|
+
sampleCount,
|
|
132
|
+
ignoreDepthStencil: false
|
|
133
|
+
});
|
|
134
|
+
depth.on('disposed', ()=>{
|
|
135
|
+
const sizedFrameBuffers = this._cachedFrameBuffers[sizeHash];
|
|
136
|
+
const entry = sizedFrameBuffers?.get(depth);
|
|
137
|
+
if (entry) {
|
|
138
|
+
for(const k in entry){
|
|
139
|
+
const index = entry[k].indexOf(fb);
|
|
140
|
+
if (index >= 0) {
|
|
141
|
+
entry[k].splice(index, 1);
|
|
142
|
+
if (entry[k].length === 0) {
|
|
143
|
+
delete entry[k];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (Object.getOwnPropertyNames(entry).length === 0) {
|
|
148
|
+
sizedFrameBuffers.delete(depth);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
fb.getColorAttachments()[0]?.dispose();
|
|
152
|
+
fb.dispose();
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
fb = fbList.pop();
|
|
156
|
+
}
|
|
157
|
+
this._releaseFuncs.set(fb, variant ? this.releaseWithDepthTexVariantSize : this.releaseWithDepthTexFixedSize);
|
|
158
|
+
return fb;
|
|
159
|
+
}
|
|
160
|
+
static releaseFramebuffer(fb) {
|
|
161
|
+
const releaseFunc = this._releaseFuncs.get(fb);
|
|
162
|
+
if (releaseFunc) {
|
|
163
|
+
releaseFunc.call(this, fb);
|
|
164
|
+
this._releaseFuncs.delete(fb);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
static releaseWithDepthTexFixedSize(fb) {
|
|
168
|
+
this.releaseFrameBufferInternal(fb, fb.getDepthAttachment(), true);
|
|
169
|
+
}
|
|
170
|
+
static releaseWithDepthTexVariantSize(fb) {
|
|
171
|
+
this.releaseFrameBufferInternal(fb, fb.getDepthAttachment(), false);
|
|
172
|
+
}
|
|
173
|
+
static releaseWithoutDepthTexFixedSize(fb) {
|
|
174
|
+
this.releaseFrameBufferInternal(fb, null, true);
|
|
175
|
+
}
|
|
176
|
+
static releaseWithoutDepthTexVariantSize(fb) {
|
|
177
|
+
this.releaseFrameBufferInternal(fb, null, false);
|
|
178
|
+
}
|
|
179
|
+
static releaseFrameBufferInternal(fb, withDepthTex, withSize) {
|
|
180
|
+
const tex = fb.getDepthAttachment() ?? fb.getColorAttachments()[0];
|
|
181
|
+
const sizeHash = withSize ? `${tex.width}x${tex.height}` : '';
|
|
182
|
+
let variantSizeFrameBuffers = this._cachedFrameBuffers[sizeHash];
|
|
183
|
+
if (!variantSizeFrameBuffers) {
|
|
184
|
+
variantSizeFrameBuffers = new Map();
|
|
185
|
+
this._cachedFrameBuffers[sizeHash] = variantSizeFrameBuffers;
|
|
186
|
+
}
|
|
187
|
+
const colorTex = fb.getColorAttachments()[0];
|
|
188
|
+
const depthTex = fb.getDepthAttachment();
|
|
189
|
+
const numLayers = colorTex?.isTexture2DArray() ? colorTex.depth : depthTex?.isTexture2DArray() ? depthTex.depth : 1;
|
|
190
|
+
const hash = `${colorTex?.format ?? ''}:${depthTex?.format ?? ''}:${colorTex ? colorTex.target : ''}:${numLayers}:${depthTex ? depthTex.target : ''}:${colorTex?.mipLevelCount > 1 ? 1 : 0}:${fb.getSampleCount()}`;
|
|
191
|
+
let entry = variantSizeFrameBuffers.get(withDepthTex);
|
|
192
|
+
if (!entry) {
|
|
193
|
+
entry = {};
|
|
194
|
+
variantSizeFrameBuffers.set(withDepthTex, entry);
|
|
195
|
+
}
|
|
196
|
+
let fblist = entry[hash];
|
|
197
|
+
if (!fblist) {
|
|
198
|
+
fblist = [];
|
|
199
|
+
entry[hash] = fblist;
|
|
200
|
+
}
|
|
201
|
+
fblist.push(fb);
|
|
202
|
+
}
|
|
203
|
+
static purgeVariantFramebuffers() {
|
|
204
|
+
const variantSizeFrameBuffers = this._cachedFrameBuffers[''];
|
|
205
|
+
variantSizeFrameBuffers?.forEach((val, key)=>{
|
|
206
|
+
for(const k in val){
|
|
207
|
+
val[k].forEach((fb)=>{
|
|
208
|
+
fb.getColorAttachments()[0].dispose();
|
|
209
|
+
fb.dispose();
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
if (this._ownDepthTextures.has(key)) {
|
|
213
|
+
this._ownDepthTextures.delete(key);
|
|
214
|
+
key?.dispose();
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
variantSizeFrameBuffers?.clear();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export { TemporalCache };
|
|
222
|
+
//# sourceMappingURL=temporalcache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporalcache.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|