@shapediver/viewer.rendering-engine.rendering-engine-threejs 3.8.2 → 3.8.3
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/managers/postprocessing/effects/ToneMappingEffect.d.ts +1 -0
- package/dist/managers/postprocessing/effects/ToneMappingEffect.d.ts.map +1 -0
- package/dist/managers/postprocessing/effects/ToneMappingEffect.js +2 -0
- package/dist/managers/postprocessing/effects/ToneMappingEffect.js.map +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.d.ts +175 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.d.ts.map +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.js +332 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.js.map +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingPass.d.ts +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingPass.d.ts.map +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingPass.js +2 -0
- package/dist/managers/postprocessing/effects/tone-mapping/ToneMappingPass.js.map +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/tone-mapping.d.ts +2 -0
- package/dist/managers/postprocessing/effects/tone-mapping/tone-mapping.d.ts.map +1 -0
- package/dist/managers/postprocessing/effects/tone-mapping/tone-mapping.js +100 -0
- package/dist/managers/postprocessing/effects/tone-mapping/tone-mapping.js.map +1 -0
- package/package.json +17 -17
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=ToneMappingEffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToneMappingEffect.d.ts","sourceRoot":"","sources":["../../../../src/managers/postprocessing/effects/ToneMappingEffect.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToneMappingEffect.js","sourceRoot":"","sources":["../../../../src/managers/postprocessing/effects/ToneMappingEffect.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { AdaptiveLuminancePass, BlendFunction, Effect, LuminancePass, ShaderPass, ToneMappingMode } from "postprocessing";
|
|
2
|
+
import { Camera, Scene, Texture, WebGLRenderTarget, WebGLRenderer } from "three";
|
|
3
|
+
/**
|
|
4
|
+
* A tone mapping effect.
|
|
5
|
+
*
|
|
6
|
+
* Note: `ToneMappingMode.REINHARD2_ADAPTIVE` requires support for `EXT_shader_texture_lod`.
|
|
7
|
+
*
|
|
8
|
+
* Reference:
|
|
9
|
+
* GDC2007 - Wolfgang Engel, Post-Processing Pipeline
|
|
10
|
+
* http://perso.univ-lyon1.fr/jean-claude.iehl/Public/educ/GAMA/2007/gdc07/Post-Processing_Pipeline.pdf
|
|
11
|
+
*/
|
|
12
|
+
export declare class ToneMappingEffect extends Effect {
|
|
13
|
+
adaptiveLuminancePass: AdaptiveLuminancePass;
|
|
14
|
+
camera: Camera;
|
|
15
|
+
depthMaskPass: ShaderPass;
|
|
16
|
+
depthPass: any;
|
|
17
|
+
luminancePass: LuminancePass;
|
|
18
|
+
renderTargetLuminance: WebGLRenderTarget;
|
|
19
|
+
renderTargetMasked: any;
|
|
20
|
+
scene: Scene;
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a new tone mapping effect.
|
|
23
|
+
*
|
|
24
|
+
* The additional parameters only affect the Reinhard2 operator.
|
|
25
|
+
*
|
|
26
|
+
* @param {Object} [options] - The options.
|
|
27
|
+
* @param {BlendFunction} [options.blendFunction=BlendFunction.SRC] - The blend function of this effect.
|
|
28
|
+
* @param {boolean} [options.adaptive=false] - Deprecated. Use mode instead.
|
|
29
|
+
* @param {ToneMappingMode} [options.mode=ToneMappingMode.AGX] - The tone mapping mode.
|
|
30
|
+
* @param {number} [options.resolution=256] - The resolution of the luminance texture. Must be a power of two.
|
|
31
|
+
* @param {number} [options.maxLuminance=4.0] - Deprecated. Same as whitePoint.
|
|
32
|
+
* @param {number} [options.whitePoint=4.0] - The white point.
|
|
33
|
+
* @param {number} [options.middleGrey=0.6] - The middle grey factor.
|
|
34
|
+
* @param {number} [options.minLuminance=0.01] - The minimum luminance. Prevents very high exposure in dark scenes.
|
|
35
|
+
* @param {number} [options.averageLuminance=1.0] - The average luminance. Used for the non-adaptive Reinhard operator.
|
|
36
|
+
* @param {number} [options.adaptationRate=1.0] - The luminance adaptation rate.
|
|
37
|
+
*/
|
|
38
|
+
constructor(scene: Scene, camera: Camera, { blendFunction, adaptive, mode, resolution, maxLuminance, whitePoint, middleGrey, minLuminance, averageLuminance, adaptationRate, }?: {
|
|
39
|
+
blendFunction?: BlendFunction;
|
|
40
|
+
adaptive?: boolean;
|
|
41
|
+
mode?: ToneMappingMode;
|
|
42
|
+
resolution?: number;
|
|
43
|
+
maxLuminance?: number;
|
|
44
|
+
whitePoint?: number;
|
|
45
|
+
middleGrey?: number;
|
|
46
|
+
minLuminance?: number;
|
|
47
|
+
averageLuminance?: number;
|
|
48
|
+
adaptationRate?: number;
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* The luminance adaptation rate.
|
|
52
|
+
*
|
|
53
|
+
* @type {number}
|
|
54
|
+
* @deprecated Use adaptiveLuminanceMaterial.adaptationRate instead.
|
|
55
|
+
*/
|
|
56
|
+
get adaptationRate(): any;
|
|
57
|
+
set adaptationRate(value: any);
|
|
58
|
+
/**
|
|
59
|
+
* Indicates whether this pass uses adaptive luminance.
|
|
60
|
+
*
|
|
61
|
+
* @type {boolean}
|
|
62
|
+
* @deprecated Use mode instead.
|
|
63
|
+
*/
|
|
64
|
+
get adaptive(): boolean;
|
|
65
|
+
set adaptive(value: boolean);
|
|
66
|
+
/**
|
|
67
|
+
* The adaptive luminance material.
|
|
68
|
+
*
|
|
69
|
+
* @type {AdaptiveLuminanceMaterial}
|
|
70
|
+
*/
|
|
71
|
+
get adaptiveLuminanceMaterial(): import("three").Material;
|
|
72
|
+
/**
|
|
73
|
+
* The average luminance.
|
|
74
|
+
*
|
|
75
|
+
* Only applies to Reinhard2 (Modified).
|
|
76
|
+
*
|
|
77
|
+
* @type {number}
|
|
78
|
+
*/
|
|
79
|
+
get averageLuminance(): any;
|
|
80
|
+
set averageLuminance(value: any);
|
|
81
|
+
get depthMaskMaterial(): any;
|
|
82
|
+
/**
|
|
83
|
+
* @type {number}
|
|
84
|
+
* @deprecated
|
|
85
|
+
*/
|
|
86
|
+
get distinction(): number;
|
|
87
|
+
set distinction(value: number);
|
|
88
|
+
set mainCamera(value: Camera);
|
|
89
|
+
set mainScene(value: Scene);
|
|
90
|
+
/**
|
|
91
|
+
* The middle grey factor. Default is `0.6`.
|
|
92
|
+
*
|
|
93
|
+
* Only applies to Reinhard2 (Modified & Adaptive).
|
|
94
|
+
*
|
|
95
|
+
* @type {number}
|
|
96
|
+
*/
|
|
97
|
+
get middleGrey(): any;
|
|
98
|
+
set middleGrey(value: any);
|
|
99
|
+
/**
|
|
100
|
+
* The tone mapping mode.
|
|
101
|
+
*
|
|
102
|
+
* @type {ToneMappingMode}
|
|
103
|
+
*/
|
|
104
|
+
get mode(): number;
|
|
105
|
+
set mode(value: number);
|
|
106
|
+
/**
|
|
107
|
+
* The resolution of the luminance texture. Must be a power of two.
|
|
108
|
+
*
|
|
109
|
+
* @type {number}
|
|
110
|
+
*/
|
|
111
|
+
get resolution(): number;
|
|
112
|
+
set resolution(value: number);
|
|
113
|
+
/**
|
|
114
|
+
* The white point. Default is `4.0`.
|
|
115
|
+
*
|
|
116
|
+
* Only applies to Reinhard2 (Modified & Adaptive).
|
|
117
|
+
*
|
|
118
|
+
* @type {number}
|
|
119
|
+
*/
|
|
120
|
+
get whitePoint(): any;
|
|
121
|
+
set whitePoint(value: any);
|
|
122
|
+
/**
|
|
123
|
+
* Returns the adaptive luminance material.
|
|
124
|
+
*
|
|
125
|
+
* @deprecated Use adaptiveLuminanceMaterial instead.
|
|
126
|
+
* @return {AdaptiveLuminanceMaterial} The material.
|
|
127
|
+
*/
|
|
128
|
+
getAdaptiveLuminanceMaterial(): import("three").Material;
|
|
129
|
+
/**
|
|
130
|
+
* Returns the current tone mapping mode.
|
|
131
|
+
*
|
|
132
|
+
* @deprecated Use mode instead.
|
|
133
|
+
* @return {ToneMappingMode} The tone mapping mode.
|
|
134
|
+
*/
|
|
135
|
+
getMode(): number;
|
|
136
|
+
/**
|
|
137
|
+
* Returns the resolution of the luminance texture.
|
|
138
|
+
*
|
|
139
|
+
* @deprecated Use resolution instead.
|
|
140
|
+
* @return {number} The resolution.
|
|
141
|
+
*/
|
|
142
|
+
getResolution(): number;
|
|
143
|
+
/**
|
|
144
|
+
* Performs initialization tasks.
|
|
145
|
+
*
|
|
146
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
147
|
+
* @param {boolean} alpha - Whether the renderer uses the alpha channel or not.
|
|
148
|
+
* @param {number} frameBufferType - The type of the main frame buffers.
|
|
149
|
+
*/
|
|
150
|
+
initialize(renderer: WebGLRenderer, alpha: boolean, frameBufferType: number): void;
|
|
151
|
+
setDepthTexture(depthTexture: Texture, depthPacking?: 3200): void;
|
|
152
|
+
/**
|
|
153
|
+
* Sets the tone mapping mode.
|
|
154
|
+
*
|
|
155
|
+
* @deprecated Use mode instead.
|
|
156
|
+
* @param {ToneMappingMode} value - The tone mapping mode.
|
|
157
|
+
*/
|
|
158
|
+
setMode(value: ToneMappingMode): void;
|
|
159
|
+
/**
|
|
160
|
+
* Sets the resolution of the luminance texture. Must be a power of two.
|
|
161
|
+
*
|
|
162
|
+
* @deprecated Use resolution instead.
|
|
163
|
+
* @param {number} value - The resolution.
|
|
164
|
+
*/
|
|
165
|
+
setResolution(value: number): void;
|
|
166
|
+
/**
|
|
167
|
+
* Updates this effect.
|
|
168
|
+
*
|
|
169
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
170
|
+
* @param {WebGLRenderTarget} inputBuffer - A frame buffer that contains the result of the previous pass.
|
|
171
|
+
* @param {number} [deltaTime] - The time between the last frame and the current one in seconds.
|
|
172
|
+
*/
|
|
173
|
+
update(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, deltaTime: number): void;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=ToneMappingEffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToneMappingEffect.d.ts","sourceRoot":"","sources":["../../../../../src/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAmD,MAAM,EAAmB,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE5L,OAAO,EAAqB,MAAM,EAAoE,KAAK,EAAE,OAAO,EAAW,iBAAiB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI/K;;;;;;;;GAQG;AAEH,qBAAa,iBAAkB,SAAQ,MAAM;IAC5C,qBAAqB,EAAE,qBAAqB,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,UAAU,CAAC;IAC1B,SAAS,EAAE,GAAG,CAAC;IACf,aAAa,EAAE,aAAa,CAAC;IAC7B,qBAAqB,EAAE,iBAAiB,CAAC;IACzC,kBAAkB,EAAE,GAAG,CAAC;IACxB,KAAK,EAAE,KAAK,CAAC;IAEpB;;;;;;;;;;;;;;;;OAgBG;gBACS,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EACzC,aAAiC,EACjC,QAAgB,EAChB,IAA0E,EAC1E,UAAgB,EAChB,YAAkB,EAClB,UAAyB,EACzB,UAAgB,EAChB,YAAmB,EACnB,gBAAsB,EACtB,cAAoB,GACpB,GAAE;QACF,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,IAAI,CAAC,EAAE,eAAe,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EA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AAE,MAAM;IAI3E,eAAe,CAAC,YAAY,EAAE,OAAO,EAAE,YAAY,OAAoB;IAK9E;;;;;OAKG;IAEI,OAAO,CAAC,KAAK,EAAE,eAAe;IAIrC;;;;;OAKG;IAEI,aAAa,CAAC,KAAK,EAAE,MAAM;IAIlC;;;;;;OAMG;IAEI,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM;CAQxF"}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToneMappingEffect = void 0;
|
|
4
|
+
const postprocessing_1 = require("postprocessing");
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
6
|
+
const three_1 = require("three");
|
|
7
|
+
const tone_mapping_1 = require("./tone-mapping");
|
|
8
|
+
/**
|
|
9
|
+
* A tone mapping effect.
|
|
10
|
+
*
|
|
11
|
+
* Note: `ToneMappingMode.REINHARD2_ADAPTIVE` requires support for `EXT_shader_texture_lod`.
|
|
12
|
+
*
|
|
13
|
+
* Reference:
|
|
14
|
+
* GDC2007 - Wolfgang Engel, Post-Processing Pipeline
|
|
15
|
+
* http://perso.univ-lyon1.fr/jean-claude.iehl/Public/educ/GAMA/2007/gdc07/Post-Processing_Pipeline.pdf
|
|
16
|
+
*/
|
|
17
|
+
class ToneMappingEffect extends postprocessing_1.Effect {
|
|
18
|
+
/**
|
|
19
|
+
* Constructs a new tone mapping effect.
|
|
20
|
+
*
|
|
21
|
+
* The additional parameters only affect the Reinhard2 operator.
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} [options] - The options.
|
|
24
|
+
* @param {BlendFunction} [options.blendFunction=BlendFunction.SRC] - The blend function of this effect.
|
|
25
|
+
* @param {boolean} [options.adaptive=false] - Deprecated. Use mode instead.
|
|
26
|
+
* @param {ToneMappingMode} [options.mode=ToneMappingMode.AGX] - The tone mapping mode.
|
|
27
|
+
* @param {number} [options.resolution=256] - The resolution of the luminance texture. Must be a power of two.
|
|
28
|
+
* @param {number} [options.maxLuminance=4.0] - Deprecated. Same as whitePoint.
|
|
29
|
+
* @param {number} [options.whitePoint=4.0] - The white point.
|
|
30
|
+
* @param {number} [options.middleGrey=0.6] - The middle grey factor.
|
|
31
|
+
* @param {number} [options.minLuminance=0.01] - The minimum luminance. Prevents very high exposure in dark scenes.
|
|
32
|
+
* @param {number} [options.averageLuminance=1.0] - The average luminance. Used for the non-adaptive Reinhard operator.
|
|
33
|
+
* @param {number} [options.adaptationRate=1.0] - The luminance adaptation rate.
|
|
34
|
+
*/
|
|
35
|
+
constructor(scene, camera, { blendFunction = postprocessing_1.BlendFunction.SRC, adaptive = false, mode = adaptive ? postprocessing_1.ToneMappingMode.REINHARD2_ADAPTIVE : postprocessing_1.ToneMappingMode.AGX, resolution = 256, maxLuminance = 4.0, whitePoint = maxLuminance, middleGrey = 0.6, minLuminance = 0.01, averageLuminance = 1.0, adaptationRate = 1.0, } = {}) {
|
|
36
|
+
super('ToneMappingEffect', tone_mapping_1.tone_mapping, {
|
|
37
|
+
attributes: postprocessing_1.EffectAttribute.DEPTH,
|
|
38
|
+
blendFunction,
|
|
39
|
+
uniforms: new Map([
|
|
40
|
+
['luminanceBuffer', new three_1.Uniform(null)],
|
|
41
|
+
['maxLuminance', new three_1.Uniform(maxLuminance)],
|
|
42
|
+
['whitePoint', new three_1.Uniform(whitePoint)],
|
|
43
|
+
['middleGrey', new three_1.Uniform(middleGrey)],
|
|
44
|
+
['averageLuminance', new three_1.Uniform(averageLuminance)]
|
|
45
|
+
])
|
|
46
|
+
});
|
|
47
|
+
this.scene = scene;
|
|
48
|
+
this.camera = camera;
|
|
49
|
+
/**
|
|
50
|
+
* The render target for the current luminance.
|
|
51
|
+
*
|
|
52
|
+
* @type {WebGLRenderTarget}
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
this.renderTargetLuminance = new three_1.WebGLRenderTarget(1, 1, {
|
|
56
|
+
minFilter: three_1.LinearMipmapLinearFilter,
|
|
57
|
+
depthBuffer: false
|
|
58
|
+
});
|
|
59
|
+
this.renderTargetLuminance.texture.generateMipmaps = true;
|
|
60
|
+
this.renderTargetLuminance.texture.name = 'Luminance';
|
|
61
|
+
/**
|
|
62
|
+
* A luminance pass.
|
|
63
|
+
*
|
|
64
|
+
* @type {ShaderPass}
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
this.luminancePass = new postprocessing_1.LuminancePass({
|
|
68
|
+
renderTarget: this.renderTargetLuminance
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* An adaptive luminance pass.
|
|
72
|
+
*
|
|
73
|
+
* @type {AdaptiveLuminancePass}
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
this.adaptiveLuminancePass = new postprocessing_1.AdaptiveLuminancePass(this.luminancePass.texture, {
|
|
77
|
+
minLuminance,
|
|
78
|
+
adaptationRate
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* A depth mask pass.
|
|
82
|
+
*
|
|
83
|
+
* @type {ShaderPass}
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
this.depthPass = new postprocessing_1.DepthPass(scene, camera);
|
|
87
|
+
this.depthMaskPass = new postprocessing_1.ShaderPass(new postprocessing_1.DepthMaskMaterial());
|
|
88
|
+
const depthMaskMaterial = this.depthMaskPass.fullscreenMaterial;
|
|
89
|
+
depthMaskMaterial.copyCameraSettings(camera);
|
|
90
|
+
depthMaskMaterial.depthBuffer1 = this.depthPass.texture;
|
|
91
|
+
depthMaskMaterial.depthPacking1 = three_1.RGBADepthPacking;
|
|
92
|
+
depthMaskMaterial.depthMode = three_1.EqualDepth;
|
|
93
|
+
depthMaskMaterial.maxDepthStrategy = postprocessing_1.DepthTestStrategy.DISCARD_MAX_DEPTH;
|
|
94
|
+
/**
|
|
95
|
+
* A render target.
|
|
96
|
+
*
|
|
97
|
+
* @type {WebGLRenderTarget}
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
this.renderTargetMasked = new three_1.WebGLRenderTarget(1, 1, { depthBuffer: false });
|
|
101
|
+
this.renderTargetMasked.texture.name = "Bloom.Masked";
|
|
102
|
+
this.uniforms.get('luminanceBuffer').value = this.adaptiveLuminancePass.texture;
|
|
103
|
+
this.resolution = resolution;
|
|
104
|
+
this.mode = mode;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The luminance adaptation rate.
|
|
108
|
+
*
|
|
109
|
+
* @type {number}
|
|
110
|
+
* @deprecated Use adaptiveLuminanceMaterial.adaptationRate instead.
|
|
111
|
+
*/
|
|
112
|
+
get adaptationRate() {
|
|
113
|
+
return this.adaptiveLuminanceMaterial.adaptationRate;
|
|
114
|
+
}
|
|
115
|
+
set adaptationRate(value) {
|
|
116
|
+
this.adaptiveLuminanceMaterial.adaptationRate = value;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Indicates whether this pass uses adaptive luminance.
|
|
120
|
+
*
|
|
121
|
+
* @type {boolean}
|
|
122
|
+
* @deprecated Use mode instead.
|
|
123
|
+
*/
|
|
124
|
+
get adaptive() {
|
|
125
|
+
return (this.mode === postprocessing_1.ToneMappingMode.REINHARD2_ADAPTIVE);
|
|
126
|
+
}
|
|
127
|
+
set adaptive(value) {
|
|
128
|
+
this.mode = value ? postprocessing_1.ToneMappingMode.REINHARD2_ADAPTIVE : postprocessing_1.ToneMappingMode.REINHARD2;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The adaptive luminance material.
|
|
132
|
+
*
|
|
133
|
+
* @type {AdaptiveLuminanceMaterial}
|
|
134
|
+
*/
|
|
135
|
+
get adaptiveLuminanceMaterial() {
|
|
136
|
+
return this.adaptiveLuminancePass.fullscreenMaterial;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The average luminance.
|
|
140
|
+
*
|
|
141
|
+
* Only applies to Reinhard2 (Modified).
|
|
142
|
+
*
|
|
143
|
+
* @type {number}
|
|
144
|
+
*/
|
|
145
|
+
get averageLuminance() {
|
|
146
|
+
return this.uniforms.get('averageLuminance').value;
|
|
147
|
+
}
|
|
148
|
+
set averageLuminance(value) {
|
|
149
|
+
this.uniforms.get('averageLuminance').value = value;
|
|
150
|
+
}
|
|
151
|
+
get depthMaskMaterial() {
|
|
152
|
+
return this.depthMaskPass.fullscreenMaterial;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* @type {number}
|
|
156
|
+
* @deprecated
|
|
157
|
+
*/
|
|
158
|
+
get distinction() {
|
|
159
|
+
console.warn(this.name, 'distinction was removed.');
|
|
160
|
+
return 1.0;
|
|
161
|
+
}
|
|
162
|
+
set distinction(value) {
|
|
163
|
+
console.warn(this.name, 'distinction was removed.');
|
|
164
|
+
}
|
|
165
|
+
set mainCamera(value) {
|
|
166
|
+
this.camera = value;
|
|
167
|
+
this.depthPass.mainCamera = value;
|
|
168
|
+
this.depthMaskMaterial.copyCameraSettings(value);
|
|
169
|
+
}
|
|
170
|
+
set mainScene(value) {
|
|
171
|
+
this.depthPass.mainScene = value;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The middle grey factor. Default is `0.6`.
|
|
175
|
+
*
|
|
176
|
+
* Only applies to Reinhard2 (Modified & Adaptive).
|
|
177
|
+
*
|
|
178
|
+
* @type {number}
|
|
179
|
+
*/
|
|
180
|
+
get middleGrey() {
|
|
181
|
+
return this.uniforms.get('middleGrey').value;
|
|
182
|
+
}
|
|
183
|
+
set middleGrey(value) {
|
|
184
|
+
this.uniforms.get('middleGrey').value = value;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The tone mapping mode.
|
|
188
|
+
*
|
|
189
|
+
* @type {ToneMappingMode}
|
|
190
|
+
*/
|
|
191
|
+
get mode() {
|
|
192
|
+
return Number(this.defines.get('TONE_MAPPING_MODE'));
|
|
193
|
+
}
|
|
194
|
+
set mode(value) {
|
|
195
|
+
if (this.mode === value) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const revision = +three_1.REVISION.replace(/\D+/g, '');
|
|
199
|
+
const cineonToneMapping = (revision >= 168) ? 'CineonToneMapping(texel)' : 'OptimizedCineonToneMapping(texel)';
|
|
200
|
+
this.defines.clear();
|
|
201
|
+
this.defines.set('TONE_MAPPING_MODE', value.toFixed(0));
|
|
202
|
+
// Use one of the built-in tone mapping operators.
|
|
203
|
+
switch (value) {
|
|
204
|
+
case postprocessing_1.ToneMappingMode.LINEAR:
|
|
205
|
+
this.defines.set('toneMapping(texel)', 'LinearToneMapping(texel)');
|
|
206
|
+
break;
|
|
207
|
+
case postprocessing_1.ToneMappingMode.REINHARD:
|
|
208
|
+
this.defines.set('toneMapping(texel)', 'ReinhardToneMapping(texel)');
|
|
209
|
+
break;
|
|
210
|
+
case postprocessing_1.ToneMappingMode.OPTIMIZED_CINEON:
|
|
211
|
+
this.defines.set('toneMapping(texel)', cineonToneMapping);
|
|
212
|
+
break;
|
|
213
|
+
case postprocessing_1.ToneMappingMode.ACES_FILMIC:
|
|
214
|
+
this.defines.set('toneMapping(texel)', 'ACESFilmicToneMapping(texel)');
|
|
215
|
+
break;
|
|
216
|
+
case postprocessing_1.ToneMappingMode.AGX:
|
|
217
|
+
this.defines.set('toneMapping(texel)', 'AgXToneMapping(texel)');
|
|
218
|
+
break;
|
|
219
|
+
case postprocessing_1.ToneMappingMode.NEUTRAL:
|
|
220
|
+
this.defines.set('toneMapping(texel)', 'NeutralToneMapping(texel)');
|
|
221
|
+
break;
|
|
222
|
+
default:
|
|
223
|
+
this.defines.set('toneMapping(texel)', 'texel');
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
this.adaptiveLuminancePass.enabled = (value === postprocessing_1.ToneMappingMode.REINHARD2_ADAPTIVE);
|
|
227
|
+
this.setChanged();
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The resolution of the luminance texture. Must be a power of two.
|
|
231
|
+
*
|
|
232
|
+
* @type {number}
|
|
233
|
+
*/
|
|
234
|
+
get resolution() {
|
|
235
|
+
return this.luminancePass.resolution.width;
|
|
236
|
+
}
|
|
237
|
+
set resolution(value) {
|
|
238
|
+
// Round the given value to the next power of two.
|
|
239
|
+
const exponent = Math.max(0, Math.ceil(Math.log2(value)));
|
|
240
|
+
const size = Math.pow(2, exponent);
|
|
241
|
+
this.luminancePass.resolution.setPreferredSize(size, size);
|
|
242
|
+
this.adaptiveLuminanceMaterial.mipLevel1x1 = exponent;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The white point. Default is `4.0`.
|
|
246
|
+
*
|
|
247
|
+
* Only applies to Reinhard2 (Modified & Adaptive).
|
|
248
|
+
*
|
|
249
|
+
* @type {number}
|
|
250
|
+
*/
|
|
251
|
+
get whitePoint() {
|
|
252
|
+
return this.uniforms.get('whitePoint').value;
|
|
253
|
+
}
|
|
254
|
+
set whitePoint(value) {
|
|
255
|
+
this.uniforms.get('whitePoint').value = value;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Returns the adaptive luminance material.
|
|
259
|
+
*
|
|
260
|
+
* @deprecated Use adaptiveLuminanceMaterial instead.
|
|
261
|
+
* @return {AdaptiveLuminanceMaterial} The material.
|
|
262
|
+
*/
|
|
263
|
+
getAdaptiveLuminanceMaterial() {
|
|
264
|
+
return this.adaptiveLuminanceMaterial;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Returns the current tone mapping mode.
|
|
268
|
+
*
|
|
269
|
+
* @deprecated Use mode instead.
|
|
270
|
+
* @return {ToneMappingMode} The tone mapping mode.
|
|
271
|
+
*/
|
|
272
|
+
getMode() {
|
|
273
|
+
return this.mode;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Returns the resolution of the luminance texture.
|
|
277
|
+
*
|
|
278
|
+
* @deprecated Use resolution instead.
|
|
279
|
+
* @return {number} The resolution.
|
|
280
|
+
*/
|
|
281
|
+
getResolution() {
|
|
282
|
+
return this.resolution;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Performs initialization tasks.
|
|
286
|
+
*
|
|
287
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
288
|
+
* @param {boolean} alpha - Whether the renderer uses the alpha channel or not.
|
|
289
|
+
* @param {number} frameBufferType - The type of the main frame buffers.
|
|
290
|
+
*/
|
|
291
|
+
initialize(renderer, alpha, frameBufferType) {
|
|
292
|
+
this.adaptiveLuminancePass.initialize(renderer, alpha, frameBufferType);
|
|
293
|
+
}
|
|
294
|
+
setDepthTexture(depthTexture, depthPacking = three_1.BasicDepthPacking) {
|
|
295
|
+
this.depthMaskMaterial.depthBuffer0 = depthTexture;
|
|
296
|
+
this.depthMaskMaterial.depthPacking0 = depthPacking;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Sets the tone mapping mode.
|
|
300
|
+
*
|
|
301
|
+
* @deprecated Use mode instead.
|
|
302
|
+
* @param {ToneMappingMode} value - The tone mapping mode.
|
|
303
|
+
*/
|
|
304
|
+
setMode(value) {
|
|
305
|
+
this.mode = value;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Sets the resolution of the luminance texture. Must be a power of two.
|
|
309
|
+
*
|
|
310
|
+
* @deprecated Use resolution instead.
|
|
311
|
+
* @param {number} value - The resolution.
|
|
312
|
+
*/
|
|
313
|
+
setResolution(value) {
|
|
314
|
+
this.resolution = value;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Updates this effect.
|
|
318
|
+
*
|
|
319
|
+
* @param {WebGLRenderer} renderer - The renderer.
|
|
320
|
+
* @param {WebGLRenderTarget} inputBuffer - A frame buffer that contains the result of the previous pass.
|
|
321
|
+
* @param {number} [deltaTime] - The time between the last frame and the current one in seconds.
|
|
322
|
+
*/
|
|
323
|
+
update(renderer, inputBuffer, deltaTime) {
|
|
324
|
+
if (this.adaptiveLuminancePass.enabled) {
|
|
325
|
+
this.depthMaskPass.render(renderer, inputBuffer, inputBuffer);
|
|
326
|
+
this.luminancePass.render(renderer, inputBuffer);
|
|
327
|
+
this.adaptiveLuminancePass.render(renderer, null, null, deltaTime);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
exports.ToneMappingEffect = ToneMappingEffect;
|
|
332
|
+
//# sourceMappingURL=ToneMappingEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToneMappingEffect.js","sourceRoot":"","sources":["../../../../../src/managers/postprocessing/effects/tone-mapping/ToneMappingEffect.ts"],"names":[],"mappings":";;;AAAA,mDAA4L;AAC5L,uDAAuD;AACvD,iCAA+K;AAE/K,iDAA8C;AAE9C;;;;;;;;GAQG;AAEH,MAAa,iBAAkB,SAAQ,uBAAM;IAU5C;;;;;;;;;;;;;;;;OAgBG;IACH,YAAY,KAAY,EAAE,MAAc,EAAE,EACzC,aAAa,GAAG,8BAAa,CAAC,GAAG,EACjC,QAAQ,GAAG,KAAK,EAChB,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,gCAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC,gCAAe,CAAC,GAAG,EAC1E,UAAU,GAAG,GAAG,EAChB,YAAY,GAAG,GAAG,EAClB,UAAU,GAAG,YAAY,EACzB,UAAU,GAAG,GAAG,EAChB,YAAY,GAAG,IAAI,EACnB,gBAAgB,GAAG,GAAG,EACtB,cAAc,GAAG,GAAG,MAYjB,EAAE;QACL,KAAK,CAAC,mBAAmB,EAAE,2BAAY,EAAE;YACxC,UAAU,EAAE,gCAAe,CAAC,KAAK;YACjC,aAAa;YACb,QAAQ,EAAE,IAAI,GAAG,CAAC;gBACjB,CAAC,iBAAiB,EAAE,IAAI,eAAO,CAAC,IAAI,CAAC,CAAC;gBACtC,CAAC,cAAc,EAAE,IAAI,eAAO,CAAC,YAAY,CAAC,CAAC;gBAC3C,CAAC,YAAY,EAAE,IAAI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;;;;;OAMG;IAEI,UAAU,CAAC,QAAuB,EAAE,KAAc,EAAE,eAAuB;QACjF,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;IACzE,CAAC;IAEM,eAAe,CAAC,YAAqB,EAAE,YAAY,GAAG,yBAAiB;QAC7E,IAAI,CAAC,iBAAiB,CAAC,YAAY,GAAG,YAAY,CAAC;QACnD,IAAI,CAAC,iBAAiB,CAAC,aAAa,GAAG,YAAY,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IAEI,OAAO,CAAC,KAAsB;QACpC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IAEI,aAAa,CAAC,KAAa;QACjC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IACzB,CAAC;IAED;;;;;;OAMG;IAEI,MAAM,CAAC,QAAuB,EAAE,WAA8B,EAAE,SAAiB;QACvF,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE;YACvC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;YAE7D,IAAI,CAAC,aAAqB,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YAC1D,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;SACnE;IACF,CAAC;CACD;AA9ZD,8CA8ZC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=ToneMappingPass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToneMappingPass.d.ts","sourceRoot":"","sources":["../../../../../src/managers/postprocessing/effects/tone-mapping/ToneMappingPass.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToneMappingPass.js","sourceRoot":"","sources":["../../../../../src/managers/postprocessing/effects/tone-mapping/ToneMappingPass.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const tone_mapping = "\n#include <tonemapping_pars_fragment>\n\nuniform float whitePoint;\n\n#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3\n\n\t// Reinhard 2\n\n\tuniform float middleGrey;\n\n\t#if TONE_MAPPING_MODE == 3\n\n\t\tuniform lowp sampler2D luminanceBuffer;\n\n\t#else\n\n\t\tuniform float averageLuminance;\n\n\t#endif\n\n\tvec3 Reinhard2ToneMapping(vec3 color) {\n\n\t\tcolor *= toneMappingExposure;\n\n\t\t// Calculate the luminance of the current pixel.\n\t\tfloat l = luminance(color);\n\n\t\t#if TONE_MAPPING_MODE == 3\n\n\t\t\t// Get the average luminance from the adaptive 1x1 buffer.\n\t\t\tfloat lumAvg = unpackRGBAToFloat(texture2D(luminanceBuffer, vec2(0.5)));\n\n\t\t#else\n\n\t\t\tfloat lumAvg = averageLuminance;\n\n\t\t#endif\n\n\t\tfloat lumScaled = (l * middleGrey) / max(lumAvg, 1e-6);\n\t\tfloat lumCompressed = lumScaled * (1.0 + lumScaled / (whitePoint * whitePoint));\n\t\tlumCompressed /= (1.0 + lumScaled);\n\n\t\treturn clamp(lumCompressed * color, 0.0, 1.0);\n\n\t}\n\n#elif TONE_MAPPING_MODE == 4\n\n\t// Uncharted 2: http://filmicworlds.com/blog/filmic-tonemapping-operators\n\n\t#define A 0.15\n\t#define B 0.50\n\t#define C 0.10\n\t#define D 0.20\n\t#define E 0.02\n\t#define F 0.30\n\n\tvec3 Uncharted2Helper(const in vec3 x) {\n\n\t\treturn ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;\n\n\t}\n\n\tvec3 Uncharted2ToneMapping(vec3 color) {\n\n\t\tcolor *= toneMappingExposure;\n\t\treturn clamp(Uncharted2Helper(color) / Uncharted2Helper(vec3(whitePoint)), 0.0, 1.0);\n\n\t}\n\n#endif\n\nvoid mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth, out vec4 outputColor) {\n\t#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3\n\n\t\toutputColor = vec4(Reinhard2ToneMapping(inputColor.rgb), inputColor.a);\n\n\t#elif TONE_MAPPING_MODE == 4\n\n\t\toutputColor = vec4(Uncharted2ToneMapping(inputColor.rgb), inputColor.a);\n\n\t#else\n\n\t\toutputColor = vec4(toneMapping(inputColor.rgb), inputColor.a);\n\n\t#endif\n\n if(depth >= 1.0) {\n outputColor = inputColor;\n } else {\n outputColor = inputColor.a * outputColor + (1.0 - inputColor.a) * inputColor; \n }\n\n}\n";
|
|
2
|
+
//# sourceMappingURL=tone-mapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tone-mapping.d.ts","sourceRoot":"","sources":["../../../../../src/managers/postprocessing/effects/tone-mapping/tone-mapping.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,unEA+FxB,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tone_mapping = void 0;
|
|
4
|
+
exports.tone_mapping = `
|
|
5
|
+
#include <tonemapping_pars_fragment>
|
|
6
|
+
|
|
7
|
+
uniform float whitePoint;
|
|
8
|
+
|
|
9
|
+
#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3
|
|
10
|
+
|
|
11
|
+
// Reinhard 2
|
|
12
|
+
|
|
13
|
+
uniform float middleGrey;
|
|
14
|
+
|
|
15
|
+
#if TONE_MAPPING_MODE == 3
|
|
16
|
+
|
|
17
|
+
uniform lowp sampler2D luminanceBuffer;
|
|
18
|
+
|
|
19
|
+
#else
|
|
20
|
+
|
|
21
|
+
uniform float averageLuminance;
|
|
22
|
+
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
vec3 Reinhard2ToneMapping(vec3 color) {
|
|
26
|
+
|
|
27
|
+
color *= toneMappingExposure;
|
|
28
|
+
|
|
29
|
+
// Calculate the luminance of the current pixel.
|
|
30
|
+
float l = luminance(color);
|
|
31
|
+
|
|
32
|
+
#if TONE_MAPPING_MODE == 3
|
|
33
|
+
|
|
34
|
+
// Get the average luminance from the adaptive 1x1 buffer.
|
|
35
|
+
float lumAvg = unpackRGBAToFloat(texture2D(luminanceBuffer, vec2(0.5)));
|
|
36
|
+
|
|
37
|
+
#else
|
|
38
|
+
|
|
39
|
+
float lumAvg = averageLuminance;
|
|
40
|
+
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
float lumScaled = (l * middleGrey) / max(lumAvg, 1e-6);
|
|
44
|
+
float lumCompressed = lumScaled * (1.0 + lumScaled / (whitePoint * whitePoint));
|
|
45
|
+
lumCompressed /= (1.0 + lumScaled);
|
|
46
|
+
|
|
47
|
+
return clamp(lumCompressed * color, 0.0, 1.0);
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#elif TONE_MAPPING_MODE == 4
|
|
52
|
+
|
|
53
|
+
// Uncharted 2: http://filmicworlds.com/blog/filmic-tonemapping-operators
|
|
54
|
+
|
|
55
|
+
#define A 0.15
|
|
56
|
+
#define B 0.50
|
|
57
|
+
#define C 0.10
|
|
58
|
+
#define D 0.20
|
|
59
|
+
#define E 0.02
|
|
60
|
+
#define F 0.30
|
|
61
|
+
|
|
62
|
+
vec3 Uncharted2Helper(const in vec3 x) {
|
|
63
|
+
|
|
64
|
+
return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
vec3 Uncharted2ToneMapping(vec3 color) {
|
|
69
|
+
|
|
70
|
+
color *= toneMappingExposure;
|
|
71
|
+
return clamp(Uncharted2Helper(color) / Uncharted2Helper(vec3(whitePoint)), 0.0, 1.0);
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth, out vec4 outputColor) {
|
|
78
|
+
#if TONE_MAPPING_MODE == 2 || TONE_MAPPING_MODE == 3
|
|
79
|
+
|
|
80
|
+
outputColor = vec4(Reinhard2ToneMapping(inputColor.rgb), inputColor.a);
|
|
81
|
+
|
|
82
|
+
#elif TONE_MAPPING_MODE == 4
|
|
83
|
+
|
|
84
|
+
outputColor = vec4(Uncharted2ToneMapping(inputColor.rgb), inputColor.a);
|
|
85
|
+
|
|
86
|
+
#else
|
|
87
|
+
|
|
88
|
+
outputColor = vec4(toneMapping(inputColor.rgb), inputColor.a);
|
|
89
|
+
|
|
90
|
+
#endif
|
|
91
|
+
|
|
92
|
+
if(depth >= 1.0) {
|
|
93
|
+
outputColor = inputColor;
|
|
94
|
+
} else {
|
|
95
|
+
outputColor = inputColor.a * outputColor + (1.0 - inputColor.a) * inputColor;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
//# sourceMappingURL=tone-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tone-mapping.js","sourceRoot":"","sources":["../../../../../src/managers/postprocessing/effects/tone-mapping/tone-mapping.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+F3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/viewer.rendering-engine.rendering-engine-threejs",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Michael Oppitz <michael@shapediver.com>",
|
|
@@ -38,21 +38,21 @@
|
|
|
38
38
|
"testEnvironment": "node"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@shapediver/viewer.data-engine.gltf-converter": "3.8.
|
|
42
|
-
"@shapediver/viewer.data-engine.shared-types": "3.8.
|
|
43
|
-
"@shapediver/viewer.data-engine.tag3d-engine": "3.8.
|
|
44
|
-
"@shapediver/viewer.rendering-engine.animation-engine": "3.8.
|
|
45
|
-
"@shapediver/viewer.rendering-engine.animation-frame-engine": "3.8.
|
|
46
|
-
"@shapediver/viewer.rendering-engine.camera-engine": "3.8.
|
|
47
|
-
"@shapediver/viewer.rendering-engine.canvas-engine": "3.8.
|
|
48
|
-
"@shapediver/viewer.rendering-engine.intersection-engine": "3.8.
|
|
49
|
-
"@shapediver/viewer.rendering-engine.light-engine": "3.8.
|
|
50
|
-
"@shapediver/viewer.rendering-engine.rendering-engine": "3.8.
|
|
51
|
-
"@shapediver/viewer.shared.global-access-objects": "3.8.
|
|
52
|
-
"@shapediver/viewer.shared.math": "3.8.
|
|
53
|
-
"@shapediver/viewer.shared.node-tree": "3.8.
|
|
54
|
-
"@shapediver/viewer.shared.services": "3.8.
|
|
55
|
-
"@shapediver/viewer.shared.types": "3.8.
|
|
41
|
+
"@shapediver/viewer.data-engine.gltf-converter": "3.8.3",
|
|
42
|
+
"@shapediver/viewer.data-engine.shared-types": "3.8.3",
|
|
43
|
+
"@shapediver/viewer.data-engine.tag3d-engine": "3.8.3",
|
|
44
|
+
"@shapediver/viewer.rendering-engine.animation-engine": "3.8.3",
|
|
45
|
+
"@shapediver/viewer.rendering-engine.animation-frame-engine": "3.8.3",
|
|
46
|
+
"@shapediver/viewer.rendering-engine.camera-engine": "3.8.3",
|
|
47
|
+
"@shapediver/viewer.rendering-engine.canvas-engine": "3.8.3",
|
|
48
|
+
"@shapediver/viewer.rendering-engine.intersection-engine": "3.8.3",
|
|
49
|
+
"@shapediver/viewer.rendering-engine.light-engine": "3.8.3",
|
|
50
|
+
"@shapediver/viewer.rendering-engine.rendering-engine": "3.8.3",
|
|
51
|
+
"@shapediver/viewer.shared.global-access-objects": "3.8.3",
|
|
52
|
+
"@shapediver/viewer.shared.math": "3.8.3",
|
|
53
|
+
"@shapediver/viewer.shared.node-tree": "3.8.3",
|
|
54
|
+
"@shapediver/viewer.shared.services": "3.8.3",
|
|
55
|
+
"@shapediver/viewer.shared.types": "3.8.3",
|
|
56
56
|
"@tweenjs/tween.js": "^18.6.4",
|
|
57
57
|
"@types/stats.js": "^0.17.0",
|
|
58
58
|
"@types/three": "0.162.0",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"stats.js": "^0.17.0",
|
|
62
62
|
"three": "0.162.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "f6785475cf62624da2392d515443b799b9c6b5e3"
|
|
65
65
|
}
|