@zephyr3d/scene 0.5.0 → 0.6.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 +1 -1
- package/dist/animation/animationset.js +37 -37
- package/dist/animation/morphtrack.js +7 -5
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/skeleton.js +11 -9
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/asset/assetmanager.js +2 -2
- package/dist/asset/loaders/gltf/gltf_loader.js +7 -3
- package/dist/asset/loaders/gltf/gltf_loader.js.map +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 +3 -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 +7 -1
- 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 +142 -1
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +1178 -745
- package/dist/index.js +11 -6
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +9 -3
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/lambert.js +6 -2
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +3 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +73 -33
- 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 +13 -4
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +13 -4
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +27 -15
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/pbrmr.js +14 -3
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +14 -3
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +36 -21
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/posteffect/bloom.js +1 -10
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js +43 -24
- 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 +44 -24
- 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 +305 -337
- 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 +5 -3
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +17 -1
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +25 -19
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +4 -2
- 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 +35 -3
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/objectcolorpass.js +2 -1
- package/dist/render/objectcolorpass.js.map +1 -1
- package/dist/render/render_queue.js +72 -52
- 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 +75 -36
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/renderpass.js +16 -13
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/shadowmap_pass.js +6 -0
- 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/scene/batchgroup.js +60 -14
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +2 -2
- package/dist/scene/graph_node.js +0 -5
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/light.js +5 -5
- package/dist/scene/mesh.js +34 -18
- 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 +1 -1
- package/dist/scene/scene_node.js +9 -5
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain/grass.js +3 -4
- 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 +3 -4
- package/dist/scene/terrain/patch.js.map +1 -1
- 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/shadowmapper.js +11 -11
- 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/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 +8 -1
- package/dist/values.js.map +1 -1
- package/package.json +4 -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/objectpool.js +0 -295
- package/dist/render/objectpool.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,61 +0,0 @@
|
|
|
1
|
-
import { Application } from '../app.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Base class for any kind of render scheme
|
|
5
|
-
* @public
|
|
6
|
-
*/ class RenderScheme {
|
|
7
|
-
/** @internal */ _shadowMapFormat;
|
|
8
|
-
/** @internal */ _enableDepthPass;
|
|
9
|
-
/** @internal */ _currentScene;
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of RenderScheme
|
|
12
|
-
*/ constructor(){
|
|
13
|
-
this._shadowMapFormat = null;
|
|
14
|
-
this._enableDepthPass = false;
|
|
15
|
-
this._currentScene = null;
|
|
16
|
-
}
|
|
17
|
-
/** True if an early depth pass is required */ get requireDepthPass() {
|
|
18
|
-
return this._enableDepthPass;
|
|
19
|
-
}
|
|
20
|
-
set requireDepthPass(val) {
|
|
21
|
-
this._enableDepthPass = !!val;
|
|
22
|
-
}
|
|
23
|
-
/** The scene that is currently been rendered */ get currentScene() {
|
|
24
|
-
return this._currentScene;
|
|
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
|
|
30
|
-
*/ renderScene(scene, camera, compositor) {
|
|
31
|
-
this._currentScene = scene;
|
|
32
|
-
const ctx = {
|
|
33
|
-
scene,
|
|
34
|
-
camera,
|
|
35
|
-
compositor
|
|
36
|
-
};
|
|
37
|
-
scene.frameUpdate();
|
|
38
|
-
if (camera && !Application.instance.device.isContextLost()) {
|
|
39
|
-
this._renderScene(ctx);
|
|
40
|
-
}
|
|
41
|
-
this._currentScene = null;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Disposes the render scheme
|
|
45
|
-
*/ dispose() {
|
|
46
|
-
this._dispose();
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Gets the texture format for shadow maps
|
|
50
|
-
* @returns Texture format for shadow maps
|
|
51
|
-
*/ getShadowMapFormat() {
|
|
52
|
-
if (!this._shadowMapFormat) {
|
|
53
|
-
const device = Application.instance.device;
|
|
54
|
-
this._shadowMapFormat = device.getDeviceCaps().textureCaps.supportHalfFloatColorBuffer ? device.type === 'webgl' ? 'rgba16f' : 'r16f' : device.getDeviceCaps().textureCaps.supportFloatColorBuffer ? device.type === 'webgl' ? 'rgba32f' : 'r32f' : 'rgba8unorm';
|
|
55
|
-
}
|
|
56
|
-
return this._shadowMapFormat;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { RenderScheme };
|
|
61
|
-
//# sourceMappingURL=renderscheme.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderscheme.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,222 +0,0 @@
|
|
|
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
|
package/dist/scene/model.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { AnimationClip } from '../animation/animation.js';
|
|
2
|
-
import { GraphNode } from './graph_node.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Model node
|
|
6
|
-
* @public
|
|
7
|
-
*/ class Model extends GraphNode {
|
|
8
|
-
/** @internal */ _animations;
|
|
9
|
-
/** @internal */ _animationIndex;
|
|
10
|
-
/** @internal */ _updateCallback;
|
|
11
|
-
/**
|
|
12
|
-
* Creates an instance of model node
|
|
13
|
-
* @param scene - The scene to which the model belongs
|
|
14
|
-
*/ constructor(scene){
|
|
15
|
-
super(scene);
|
|
16
|
-
this._animations = {};
|
|
17
|
-
this._animationIndex = 0;
|
|
18
|
-
this._updateCallback = (evt)=>{
|
|
19
|
-
if (this.attached) {
|
|
20
|
-
this.update();
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Creates a new animation for the model
|
|
26
|
-
* @param name - Name of the animation to be created
|
|
27
|
-
* @returns The created animation
|
|
28
|
-
*/ createAnimation(name) {
|
|
29
|
-
if (!name) {
|
|
30
|
-
for(;;){
|
|
31
|
-
name = `animation${this._animationIndex++}`;
|
|
32
|
-
if (!this._animationIndex[name]) {
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (this._animations[name]) {
|
|
38
|
-
console.error(`Model.createAnimation() failed: animation '${name}' already exists`);
|
|
39
|
-
return null;
|
|
40
|
-
} else {
|
|
41
|
-
const ani = new AnimationClip(name, this);
|
|
42
|
-
this._animations[name] = ani;
|
|
43
|
-
return ani;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Deletes an animation of this model
|
|
48
|
-
* @param name - Name of the animation to be deleted
|
|
49
|
-
*/ deleteAnimation(name) {
|
|
50
|
-
this.stopAnimation(name);
|
|
51
|
-
delete this._animations[name];
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Gets names of all the animations of the model
|
|
55
|
-
* @returns An array of string that contains the animation names
|
|
56
|
-
*/ getAnimationNames() {
|
|
57
|
-
return Object.keys(this._animations);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Updates all animations of the model
|
|
61
|
-
*/ update() {
|
|
62
|
-
for(const k in this._animations){
|
|
63
|
-
this._animations[k].update();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Checks whether an animation is playing
|
|
68
|
-
* @param name - Name of the animation to be checked
|
|
69
|
-
* @returns true if the animation is playing, otherwise false
|
|
70
|
-
*/ isPlayingAnimation(name) {
|
|
71
|
-
if (name) {
|
|
72
|
-
return this._animations[name]?.isPlaying();
|
|
73
|
-
} else {
|
|
74
|
-
for(const k in this._animations){
|
|
75
|
-
if (this._animations[k].isPlaying()) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Starts playing an animation of the model
|
|
84
|
-
* @param name - Name of the animation to play
|
|
85
|
-
* @param repeat - The repeat times, 0 for always repeating
|
|
86
|
-
*/ playAnimation(name, repeat = 1) {
|
|
87
|
-
const ani = this._animations[name];
|
|
88
|
-
if (ani && !ani.isPlaying()) {
|
|
89
|
-
for (const name of this.getAnimationNames()){
|
|
90
|
-
if (this.isPlayingAnimation(name)) {
|
|
91
|
-
this.stopAnimation(name);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
ani.play(repeat, 1);
|
|
95
|
-
this.scene.on('sceneupdate', this._updateCallback);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Stops playing an animation of the model
|
|
100
|
-
* @param name - Name of the animation to stop playing
|
|
101
|
-
*/ stopAnimation(name) {
|
|
102
|
-
const isPlaying = this.isPlayingAnimation();
|
|
103
|
-
this._animations[name]?.stop();
|
|
104
|
-
if (isPlaying && !this.isPlayingAnimation()) {
|
|
105
|
-
this.scene.off('sceneupdate', this._updateCallback);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export { Model };
|
|
111
|
-
//# sourceMappingURL=model.js.map
|
package/dist/scene/model.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { GraphNode } from './graph_node.js';
|
|
2
|
-
|
|
3
|
-
/** @internal */ class OctreeUpdateVisitor {
|
|
4
|
-
/** @internal */ _octree;
|
|
5
|
-
constructor(octree){
|
|
6
|
-
this._octree = octree;
|
|
7
|
-
}
|
|
8
|
-
visit(node) {
|
|
9
|
-
if (node instanceof GraphNode) {
|
|
10
|
-
if (node.placeToOctree) {
|
|
11
|
-
this._octree.placeNode(node);
|
|
12
|
-
} else {
|
|
13
|
-
this._octree.removeNode(node);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { OctreeUpdateVisitor };
|
|
20
|
-
//# sourceMappingURL=octree_update_visitor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"octree_update_visitor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
|
package/dist/shaders/builtins.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { ShaderFramework } from './framework.js';
|
|
2
|
-
import { encodeColorOutput } from './misc.js';
|
|
3
|
-
import '../app.js';
|
|
4
|
-
import { ScatteringLut } from '../render/scatteringlut.js';
|
|
5
|
-
|
|
6
|
-
const MESH_MATERIAL = {
|
|
7
|
-
FRAGMENT_SHADER (scope, ctx) {
|
|
8
|
-
ShaderFramework.prepareFragmentShader(scope.$builder, ctx);
|
|
9
|
-
},
|
|
10
|
-
VERTEX_SHADER (scope, ctx) {
|
|
11
|
-
ShaderFramework.prepareVertexShader(scope.$builder, ctx);
|
|
12
|
-
},
|
|
13
|
-
FTRANSFORM (scope) {
|
|
14
|
-
ShaderFramework.ftransform(scope);
|
|
15
|
-
},
|
|
16
|
-
DEFINE_VERTEX_COLOR (color) {
|
|
17
|
-
return color.tag(ShaderFramework.USAGE_VERTEX_COLOR);
|
|
18
|
-
},
|
|
19
|
-
DEFINE_WORLD_NORMAL (normal) {
|
|
20
|
-
return normal.tag(ShaderFramework.USAGE_WORLD_NORMAL);
|
|
21
|
-
},
|
|
22
|
-
DEFINE_WORLD_TANGENT (tangent) {
|
|
23
|
-
return tangent.tag(ShaderFramework.USAGE_WORLD_TANGENT);
|
|
24
|
-
},
|
|
25
|
-
DEFINE_WORLD_BINORMAL (binormal) {
|
|
26
|
-
return binormal.tag(ShaderFramework.USAGE_WORLD_BINORMAL);
|
|
27
|
-
},
|
|
28
|
-
DEFINE_WORLD_POSITION (pos) {
|
|
29
|
-
return pos.tag(ShaderFramework.USAGE_WORLD_POSITION);
|
|
30
|
-
},
|
|
31
|
-
FRAGMENT_OUTPUT (scope, color) {
|
|
32
|
-
return encodeColorOutput(scope, color);
|
|
33
|
-
},
|
|
34
|
-
GET_WORLD_MATRIX (scope) {
|
|
35
|
-
return ShaderFramework.getWorldMatrix(scope);
|
|
36
|
-
},
|
|
37
|
-
GET_VIEW_PROJ_MATRIX (scope) {
|
|
38
|
-
return ShaderFramework.getViewProjectionMatrix(scope);
|
|
39
|
-
},
|
|
40
|
-
GET_ENVLIGHT_STRENGTH (scope) {
|
|
41
|
-
return ShaderFramework.getEnvLightStrength(scope);
|
|
42
|
-
},
|
|
43
|
-
GET_CAMERA_POSITION (scope) {
|
|
44
|
-
return ShaderFramework.getCameraPosition(scope);
|
|
45
|
-
},
|
|
46
|
-
GET_CAMERA_PARAMS (scope) {
|
|
47
|
-
return ShaderFramework.getCameraParams(scope);
|
|
48
|
-
},
|
|
49
|
-
GET_WORLD_POSITION (scope) {
|
|
50
|
-
return ShaderFramework.getWorldPosition(scope);
|
|
51
|
-
},
|
|
52
|
-
GET_WORLD_NORMAL (scope) {
|
|
53
|
-
return ShaderFramework.getWorldNormal(scope);
|
|
54
|
-
},
|
|
55
|
-
GET_WORLD_TANGENT (scope) {
|
|
56
|
-
return ShaderFramework.getWorldTangent(scope);
|
|
57
|
-
},
|
|
58
|
-
GET_WORLD_BINORMAL (scope) {
|
|
59
|
-
return ShaderFramework.getWorldBinormal(scope);
|
|
60
|
-
},
|
|
61
|
-
SET_CLIP_SPACE_POSITION (scope, pos) {
|
|
62
|
-
ShaderFramework.setClipSpacePosition(scope, pos);
|
|
63
|
-
},
|
|
64
|
-
DISCARD_IF_CLIPPED (scope) {
|
|
65
|
-
ShaderFramework.discardIfClipped(scope);
|
|
66
|
-
},
|
|
67
|
-
APPLY_FOG (scope, color, ctx) {
|
|
68
|
-
if (ctx.applyFog) {
|
|
69
|
-
const pb = scope.$builder;
|
|
70
|
-
if (ctx.env.sky.drawScatteredFog(ctx)) {
|
|
71
|
-
const funcName = 'applyAerialPerspective';
|
|
72
|
-
pb.func(funcName, [
|
|
73
|
-
pb.vec4('color').inout()
|
|
74
|
-
], function() {
|
|
75
|
-
this.$l.viewDir = pb.sub(ShaderFramework.getWorldPosition(this).xyz, ShaderFramework.getCameraPosition(this));
|
|
76
|
-
this.viewDir.y = pb.max(this.viewDir.y, 0);
|
|
77
|
-
this.$l.distance = pb.mul(pb.length(this.viewDir), ShaderFramework.getWorldUnit(this));
|
|
78
|
-
this.$l.sliceDist = pb.div(pb.mul(ShaderFramework.getCameraParams(this).y, ShaderFramework.getWorldUnit(this)), ScatteringLut.aerialPerspectiveSliceZ);
|
|
79
|
-
this.$l.slice0 = pb.floor(pb.div(this.distance, this.sliceDist));
|
|
80
|
-
this.$l.slice1 = pb.add(this.slice0, 1);
|
|
81
|
-
this.$l.factor = pb.sub(pb.div(this.distance, this.sliceDist), this.slice0);
|
|
82
|
-
this.$l.viewNormal = pb.normalize(this.viewDir);
|
|
83
|
-
this.$l.zenithAngle = pb.asin(this.viewNormal.y);
|
|
84
|
-
this.$l.horizonAngle = pb.atan2(this.viewNormal.z, this.viewNormal.x);
|
|
85
|
-
this.$l.u0 = pb.div(pb.add(this.slice0, pb.div(this.horizonAngle, Math.PI * 2)), ScatteringLut.aerialPerspectiveSliceZ);
|
|
86
|
-
this.$l.u1 = pb.add(this.u0, 1 / ScatteringLut.aerialPerspectiveSliceZ);
|
|
87
|
-
this.$l.v = pb.div(this.zenithAngle, Math.PI / 2);
|
|
88
|
-
this.$l.t0 = pb.textureSampleLevel(ShaderFramework.getAerialPerspectiveLUT(this), pb.vec2(this.u0, this.v), 0);
|
|
89
|
-
this.$l.t1 = pb.textureSampleLevel(ShaderFramework.getAerialPerspectiveLUT(this), pb.vec2(this.u1, this.v), 0);
|
|
90
|
-
this.$l.t = pb.mix(this.t0, this.t1, this.factor);
|
|
91
|
-
this.color = pb.vec4(pb.add(pb.mul(this.color.rgb, this.factor), this.t.rgb), this.color.a);
|
|
92
|
-
});
|
|
93
|
-
scope[funcName](color);
|
|
94
|
-
} else {
|
|
95
|
-
const funcName = 'applyFog';
|
|
96
|
-
pb.func(funcName, [
|
|
97
|
-
pb.vec4('color').inout()
|
|
98
|
-
], function() {
|
|
99
|
-
this.$l.viewDir = pb.sub(ShaderFramework.getWorldPosition(this).xyz, ShaderFramework.getCameraPosition(this));
|
|
100
|
-
this.$l.fogFactor = ShaderFramework.computeFogFactor(this, this.viewDir, ShaderFramework.getFogType(this), ShaderFramework.getFogParams(this));
|
|
101
|
-
this.color = pb.vec4(pb.mix(this.color.rgb, ShaderFramework.getFogColor(this).rgb, pb.mul(this.fogFactor, this.color.a, this.color.a)), this.color.a);
|
|
102
|
-
});
|
|
103
|
-
scope[funcName](color);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export { MESH_MATERIAL };
|
|
110
|
-
//# sourceMappingURL=builtins.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builtins.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|