rayzee 8.4.0 → 8.4.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 +5 -1
- package/dist/rayzee.es.js +1094 -1043
- package/dist/rayzee.umd.js +37 -35
- package/package.json +1 -1
- package/src/EngineDefaults.js +5 -5
- package/src/EngineIssues.js +1 -0
- package/src/LightUnits.js +122 -0
- package/src/PathTracerApp.js +4 -2
- package/src/Processor/AssetLoader.js +61 -43
- package/src/Processor/LightSerializer.js +17 -9
- package/src/Stages/PathTracer.js +23 -3
- package/src/TSL/LightsCore.js +8 -3
- package/src/TSL/LightsSampling.js +1 -4
- package/src/index.js +1 -0
- package/src/managers/DenoisingManager.js +16 -0
- package/src/managers/LightManager.js +15 -17
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
EventDispatcher, DirectionalLight, PointLight, SpotLight, RectAreaLight,
|
|
3
3
|
Object3D, MathUtils
|
|
4
4
|
} from 'three';
|
|
5
|
+
import { bakeAreaLightScale, lightPower, setLightPower } from '../LightUnits.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Manages scene lights: add, remove, transfer from mesh scene to WebGPU
|
|
@@ -37,12 +38,13 @@ export class LightManager extends EventDispatcher {
|
|
|
37
38
|
*/
|
|
38
39
|
addLight( type ) {
|
|
39
40
|
|
|
41
|
+
// Authored as Blender Power in Watts (the Sun as W/m²), converted to the stored
|
|
42
|
+
// quantity by setLightPower() once the light exists — see LightUnits.js.
|
|
40
43
|
const defaults = {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
RectAreaLight: { position: [ 0, 2, 0 ], intensity: 100, color: '#ffffff', width: 2, height: 2 }
|
|
44
|
+
DirectionalLight: { position: [ 1, 1, 1 ], power: 1.0, color: '#ffffff' },
|
|
45
|
+
PointLight: { position: [ 0, 2, 0 ], power: 1000, color: '#ffffff' },
|
|
46
|
+
SpotLight: { position: [ 0, 1, 0 ], power: 1000, color: '#ffffff', angle: 15 },
|
|
47
|
+
RectAreaLight: { position: [ 0, 2, 0 ], power: 100, color: '#ffffff', width: 2, height: 2 }
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
const props = defaults[ type ];
|
|
@@ -52,17 +54,17 @@ export class LightManager extends EventDispatcher {
|
|
|
52
54
|
|
|
53
55
|
if ( type === 'DirectionalLight' ) {
|
|
54
56
|
|
|
55
|
-
light = new DirectionalLight( props.color,
|
|
57
|
+
light = new DirectionalLight( props.color, 1 );
|
|
56
58
|
light.position.fromArray( props.position );
|
|
57
59
|
|
|
58
60
|
} else if ( type === 'PointLight' ) {
|
|
59
61
|
|
|
60
|
-
light = new PointLight( props.color,
|
|
62
|
+
light = new PointLight( props.color, 1 );
|
|
61
63
|
light.position.fromArray( props.position );
|
|
62
64
|
|
|
63
65
|
} else if ( type === 'SpotLight' ) {
|
|
64
66
|
|
|
65
|
-
light = new SpotLight( props.color,
|
|
67
|
+
light = new SpotLight( props.color, 1 );
|
|
66
68
|
light.position.fromArray( props.position );
|
|
67
69
|
light.angle = MathUtils.degToRad( props.angle );
|
|
68
70
|
const target = new Object3D();
|
|
@@ -71,7 +73,7 @@ export class LightManager extends EventDispatcher {
|
|
|
71
73
|
|
|
72
74
|
} else if ( type === 'RectAreaLight' ) {
|
|
73
75
|
|
|
74
|
-
light = new RectAreaLight( props.color,
|
|
76
|
+
light = new RectAreaLight( props.color, 1, props.width, props.height );
|
|
75
77
|
light.position.fromArray( props.position );
|
|
76
78
|
light.lookAt( 0, 0, 0 );
|
|
77
79
|
// Blender-style emission defaults: power-normalized, full Lambertian
|
|
@@ -82,6 +84,8 @@ export class LightManager extends EventDispatcher {
|
|
|
82
84
|
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
setLightPower( light, props.power );
|
|
88
|
+
|
|
85
89
|
// Blender-style emission controls common to every light type.
|
|
86
90
|
light.userData.temperature = 6500;
|
|
87
91
|
light.userData.useTemperature = false;
|
|
@@ -178,13 +182,7 @@ export class LightManager extends EventDispatcher {
|
|
|
178
182
|
light.getWorldQuaternion( cloned.quaternion );
|
|
179
183
|
light.getWorldScale( cloned.scale );
|
|
180
184
|
|
|
181
|
-
if ( cloned.isRectAreaLight )
|
|
182
|
-
|
|
183
|
-
cloned.width *= cloned.scale.x;
|
|
184
|
-
cloned.height *= cloned.scale.y;
|
|
185
|
-
cloned.scale.set( 1, 1, 1 );
|
|
186
|
-
|
|
187
|
-
}
|
|
185
|
+
if ( cloned.isRectAreaLight ) bakeAreaLightScale( cloned );
|
|
188
186
|
|
|
189
187
|
if ( ( light.isSpotLight || light.isDirectionalLight ) && light.target ) {
|
|
190
188
|
|
|
@@ -338,7 +336,7 @@ export class LightManager extends EventDispatcher {
|
|
|
338
336
|
name: light.name,
|
|
339
337
|
type: light.type,
|
|
340
338
|
visible: light.visible,
|
|
341
|
-
intensity: light.
|
|
339
|
+
intensity: lightPower( light ), // Blender Power (W); the light stores the three.js quantity
|
|
342
340
|
color: `#${light.color.getHexString()}`,
|
|
343
341
|
position: [ light.position.x, light.position.y, light.position.z ],
|
|
344
342
|
angle,
|