@carbonenginejs/runtime 0.1.0-alpha.6 → 0.1.0-alpha.7
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.
Potentially problematic release.
This version of @carbonenginejs/runtime might be problematic. Click here for more details.
- package/dist/global/consts/effectPaths.js +4 -1
- package/dist/global/consts/effectPaths.js.map +1 -1
- package/dist/global/consts/index.js +1 -1
- package/dist/global/index.js +1 -1
- package/dist/index.js +3 -3
- package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js +19 -2
- package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
- package/dist/resource/format/index.js +1 -1
- package/dist/resource/formats/hlsl/core/carbonTypedViews.js +121 -65
- package/dist/resource/formats/hlsl/core/carbonTypedViews.js.map +1 -1
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js +10 -7
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
- package/dist/resource/formats/webgpu/core/effectBackendBodySet.js +3 -1
- package/dist/resource/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/resource/formats/webgpu/core/packageEffect.js +5 -0
- package/dist/resource/formats/webgpu/core/packageEffect.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/emitWgsl.js +20 -0
- package/dist/resource/formats/webgpu/core/wgsl/emitWgsl.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/emulatedAddressing.js +93 -4
- package/dist/resource/formats/webgpu/core/wgsl/emulatedAddressing.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js +74 -64
- package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/lowerFragmentProgram.js +16 -7
- package/dist/resource/formats/webgpu/core/wgsl/lowerFragmentProgram.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/wgslTypedViews.js +69 -27
- package/dist/resource/formats/webgpu/core/wgsl/wgslTypedViews.js.map +1 -1
- package/dist/resource/geometry/registerGeometryResources.js +10 -1
- package/dist/resource/geometry/registerGeometryResources.js.map +1 -1
- package/dist/sof/EveSOFDNA.js +4 -2
- package/dist/sof/EveSOFDNA.js.map +1 -1
- package/dist/sof/EveSOFDataMgr.js +83 -69
- package/dist/sof/EveSOFDataMgr.js.map +1 -1
- package/dist/trinity/core/Tr2Denoiser.js +6 -1
- package/dist/trinity/core/Tr2Denoiser.js.map +1 -1
- package/dist/trinity/core/Tr2ShadowMap.js +7 -2
- package/dist/trinity/core/Tr2ShadowMap.js.map +1 -1
- package/dist/trinity/core/context/Tr2RenderContext.js +43 -0
- package/dist/trinity/core/context/Tr2RenderContext.js.map +1 -1
- package/dist/trinity/core/device/Tr2GpuStructuredBuffer.js +134 -0
- package/dist/trinity/core/device/Tr2GpuStructuredBuffer.js.map +1 -0
- package/dist/trinity/core/index.js +1 -0
- package/dist/trinity/core/index.js.map +1 -1
- package/dist/trinity/core/lighting/Tr2LightManager.js +410 -124
- package/dist/trinity/core/lighting/Tr2LightManager.js.map +1 -1
- package/dist/trinity/eve/effect/lensflare/EveLensflare.js +303 -312
- package/dist/trinity/eve/effect/lensflare/EveLensflare.js.map +1 -1
- package/dist/trinity/eve/effect/lensflare/EveOccluder.js +117 -0
- package/dist/trinity/eve/effect/lensflare/EveOccluder.js.map +1 -0
- package/dist/trinity/eve/index.js +1 -0
- package/dist/trinity/eve/index.js.map +1 -1
- package/dist/trinity/eve/scene/EveSpaceScene.js +286 -6
- package/dist/trinity/eve/scene/EveSpaceScene.js.map +1 -1
- package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js +212 -32
- package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js.map +1 -1
- package/dist/trinity/generated/eve/effect/index.js +0 -1
- package/dist/trinity/generated/eve/effect/index.js.map +1 -1
- package/dist/trinity/generated/eve/index.js +0 -1
- package/dist/trinity/generated/eve/index.js.map +1 -1
- package/dist/trinity/generated/index.js +0 -2
- package/dist/trinity/generated/index.js.map +1 -1
- package/dist/trinity/generated/trinityCore/index.js +0 -1
- package/dist/trinity/generated/trinityCore/index.js.map +1 -1
- package/dist/trinity/index.js +2 -2
- package/dist/trinity/postProcess/Tr2PostProcessRenderer.js +4 -1
- package/dist/trinity/postProcess/Tr2PostProcessRenderer.js.map +1 -1
- package/dist/trinity/postProcess/Tr2SSAO.js +282 -21
- package/dist/trinity/postProcess/Tr2SSAO.js.map +1 -1
- package/dist/trinity/shader/parameter/Tr2RuntimeTextureParameter.js +71 -53
- package/dist/trinity/shader/parameter/Tr2RuntimeTextureParameter.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js +81 -18
- package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuResourceSetAL.js +46 -4
- package/dist/trinityal/webgpu/CjsWebgpuResourceSetAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuShaderAL.js +32 -1
- package/dist/trinityal/webgpu/CjsWebgpuShaderAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuShaderProgramAL.js +27 -0
- package/dist/trinityal/webgpu/CjsWebgpuShaderProgramAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js +29 -4
- package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js.map +1 -1
- package/dist/trinityal/webgpu/core/CjsWebgpuPsoDescription.js +32 -2
- package/dist/trinityal/webgpu/core/CjsWebgpuPsoDescription.js.map +1 -1
- package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js +57 -5
- package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js.map +1 -1
- package/dist/trinityal/webgpu/core/CjsWebgpuWorkQueue.js +111 -5
- package/dist/trinityal/webgpu/core/CjsWebgpuWorkQueue.js.map +1 -1
- package/docs/trinity/reference/classes/generated.md +20 -20
- package/docs/trinity/reference/classes/post-process.md +1 -1
- package/package.json +1 -1
- package/dist/trinity/generated/eve/effect/EveOccluder.js +0 -38
- package/dist/trinity/generated/eve/effect/EveOccluder.js.map +0 -1
- package/dist/trinity/generated/trinityCore/Tr2GpuStructuredBuffer.js +0 -48
- package/dist/trinity/generated/trinityCore/Tr2GpuStructuredBuffer.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { applyDecs2311 as _applyDecs2311 } from '../../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import { edit, type, carbon, impl } from '#schema';
|
|
3
3
|
import { CjsModel } from '#model';
|
|
4
4
|
import { mat4 } from '#math/mat4';
|
|
@@ -18,340 +18,331 @@ const bitsAsFloat = value => new Float32Array(new Uint32Array([value >>> 0]).buf
|
|
|
18
18
|
|
|
19
19
|
/** Represents a lens-flare graph with CPU-side visibility and controller state. */
|
|
20
20
|
let _EveLensflare;
|
|
21
|
-
|
|
22
|
-
static
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
#controllerVariables = (_initProto(this), new Map());
|
|
21
|
+
class EveLensflare extends CjsModel {
|
|
22
|
+
static {
|
|
23
|
+
({
|
|
24
|
+
e: [_init_translationCurve, _init_extra_translationCurve, _init_mesh, _init_extra_mesh, _init_name, _init_extra_name, _init_backgroundOccluders, _init_extra_backgroundOccluders, _init_occluders, _init_extra_occluders, _init_curveSets, _init_extra_curveSets, _init_distanceToEdgeCurves, _init_extra_distanceToEdgeCurves, _init_distanceToCenterCurves, _init_extra_distanceToCenterCurves, _init_radialAngleCurves, _init_extra_radialAngleCurves, _init_xDistanceToCenter, _init_extra_xDistanceToCenter, _init_yDistanceToCenter, _init_extra_yDistanceToCenter, _init_controllers, _init_extra_controllers, _init_bindings, _init_extra_bindings, _init_cameraFactor, _init_extra_cameraFactor, _init_position, _init_extra_position, _init_flares, _init_extra_flares, _init_update, _init_extra_update, _init_display, _init_extra_display, _initProto],
|
|
25
|
+
c: [_EveLensflare, _initClass]
|
|
26
|
+
} = _applyDecs2311(this, [type.define({
|
|
27
|
+
className: "EveLensflare",
|
|
28
|
+
family: "eve/effect"
|
|
29
|
+
}), carbon.inherit(ITr2Renderable)], [[[edit, edit.readwrite, void 0, type.objectRef("ITriVectorFunction")], 16, "translationCurve"], [[edit, edit.readwrite, edit, edit.persist, void 0, type.model("Tr2Mesh")], 16, "mesh"], [[edit, edit.readwrite, edit, edit.persist, type, type.string], 16, "name"], [[edit, edit.read, edit, edit.persist, void 0, type.list("EveOccluder")], 16, "backgroundOccluders"], [[edit, edit.read, edit, edit.persist, void 0, type.list("EveOccluder")], 16, "occluders"], [[edit, edit.read, edit, edit.persist, void 0, type.list("TriCurveSet")], 16, "curveSets"], [[edit, edit.read, edit, edit.persist, void 0, type.list("ITriFunction")], 16, "distanceToEdgeCurves"], [[edit, edit.read, edit, edit.persist, void 0, type.list("ITriFunction")], 16, "distanceToCenterCurves"], [[edit, edit.read, edit, edit.persist, void 0, type.list("ITriFunction")], 16, "radialAngleCurves"], [[edit, edit.read, edit, edit.persist, void 0, type.list("ITriFunction")], 16, "xDistanceToCenter"], [[edit, edit.read, edit, edit.persist, void 0, type.list("ITriFunction")], 16, "yDistanceToCenter"], [[edit, edit.read, edit, edit.persist, void 0, type.list("ITr2Controller")], 16, "controllers"], [[edit, edit.read, edit, edit.persist, void 0, type.list("ITr2ValueBinding")], 16, "bindings"], [[edit, edit.readwrite, edit, edit.persist, type, type.float32], 16, "cameraFactor"], [[edit, edit.readwrite, edit, edit.persist, type, type.vec3], 16, "position"], [[edit, edit.read, edit, edit.persist, void 0, type.list("EveTransform")], 16, "flares"], [[edit, edit.readwrite, edit, edit.persist, type, type.boolean], 16, "update"], [[edit, edit.readwrite, edit, edit.persist, type, type.boolean], 16, "display"], [[carbon, carbon.method, impl, impl.implemented], 18, "Update"], [[carbon, carbon.method, impl, impl.implemented], 18, "UpdateVisibility"], [[carbon, carbon.method, impl, impl.implemented], 18, "RunOcclusionQueries"], [[carbon, carbon.method, impl, impl.implemented], 18, "RunBackgroundOcclusionQueries"], [[carbon, carbon.method, impl, impl.implemented], 18, "SetControllerVariable"], [[carbon, carbon.method, impl, impl.implemented], 18, "HandleControllerEvent"], [[carbon, carbon.method, impl, impl.implemented], 18, "StartControllers"], [[carbon, carbon.method, impl, impl.adapted], 18, "PrepareRender"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetRenderables"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetBatches"], [[carbon, carbon.method, impl, impl.implemented], 18, "HasTransparentBatches"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetSortValue"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetPerObjectData"]], 0, void 0, CjsModel));
|
|
30
|
+
}
|
|
31
|
+
#controllerVariables = (_initProto(this), new Map());
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
/** m_translationCurve (ITriVectorFunctionPtr) [READWRITE] */
|
|
34
|
+
translationCurve = _init_translationCurve(this, null);
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
this.#occScaleVar.SetValue([bitsAsFloat(this.occlusionOffset ?? 0), bitsAsFloat(this.backgroundOcclusionOffset ?? 0), 0, 0]);
|
|
143
|
-
for (const curveSet of this.curveSets) {
|
|
144
|
-
curveSet?.Update(realTime, simTime);
|
|
145
|
-
}
|
|
146
|
-
for (const controller of this.controllers) {
|
|
147
|
-
controller?.Update(0.5);
|
|
148
|
-
}
|
|
36
|
+
/** m_mesh (Tr2MeshPtr) [READWRITE, PERSIST] */
|
|
37
|
+
mesh = (_init_extra_translationCurve(this), _init_mesh(this, null));
|
|
38
|
+
|
|
39
|
+
/** m_name (std::string) [READWRITE, PERSIST] */
|
|
40
|
+
name = (_init_extra_mesh(this), _init_name(this, ""));
|
|
41
|
+
|
|
42
|
+
/** m_backgroundOccluders (PEveOccluderVector) [READ, PERSIST] */
|
|
43
|
+
backgroundOccluders = (_init_extra_name(this), _init_backgroundOccluders(this, []));
|
|
44
|
+
|
|
45
|
+
/** m_occluders (PEveOccluderVector) [READ, PERSIST] */
|
|
46
|
+
occluders = (_init_extra_backgroundOccluders(this), _init_occluders(this, []));
|
|
47
|
+
|
|
48
|
+
/** m_curveSets (PTriCurveSetVector) [READ, PERSIST] */
|
|
49
|
+
curveSets = (_init_extra_occluders(this), _init_curveSets(this, []));
|
|
50
|
+
|
|
51
|
+
/** m_distanceToEdgeCurves (PITriFunctionVector) [READ, PERSIST] */
|
|
52
|
+
distanceToEdgeCurves = (_init_extra_curveSets(this), _init_distanceToEdgeCurves(this, []));
|
|
53
|
+
|
|
54
|
+
/** m_distanceToCenterCurves (PITriFunctionVector) [READ, PERSIST] */
|
|
55
|
+
distanceToCenterCurves = (_init_extra_distanceToEdgeCurves(this), _init_distanceToCenterCurves(this, []));
|
|
56
|
+
|
|
57
|
+
/** m_radialAngleCurves (PITriFunctionVector) [READ, PERSIST] */
|
|
58
|
+
radialAngleCurves = (_init_extra_distanceToCenterCurves(this), _init_radialAngleCurves(this, []));
|
|
59
|
+
|
|
60
|
+
/** m_xDistanceToCenter (PITriFunctionVector) [READ, PERSIST] */
|
|
61
|
+
xDistanceToCenter = (_init_extra_radialAngleCurves(this), _init_xDistanceToCenter(this, []));
|
|
62
|
+
|
|
63
|
+
/** m_yDistanceToCenter (PITriFunctionVector) [READ, PERSIST] */
|
|
64
|
+
yDistanceToCenter = (_init_extra_xDistanceToCenter(this), _init_yDistanceToCenter(this, []));
|
|
65
|
+
|
|
66
|
+
/** m_controllers (PITr2ControllerVector) [READ, PERSIST] */
|
|
67
|
+
controllers = (_init_extra_yDistanceToCenter(this), _init_controllers(this, []));
|
|
68
|
+
|
|
69
|
+
/** m_bindings (PITr2ValueBindingVector) [READ, PERSIST] */
|
|
70
|
+
bindings = (_init_extra_controllers(this), _init_bindings(this, []));
|
|
71
|
+
|
|
72
|
+
/** m_cameraFactor (float) [READWRITE, PERSIST] */
|
|
73
|
+
cameraFactor = (_init_extra_bindings(this), _init_cameraFactor(this, 20));
|
|
74
|
+
|
|
75
|
+
/** m_position (Vector3) [READWRITE, PERSIST] */
|
|
76
|
+
position = (_init_extra_cameraFactor(this), _init_position(this, vec3.create()));
|
|
77
|
+
|
|
78
|
+
/** m_flares (PEveTransformVector) [READ, PERSIST] */
|
|
79
|
+
flares = (_init_extra_position(this), _init_flares(this, []));
|
|
80
|
+
|
|
81
|
+
/** m_update (bool) [READWRITE, PERSIST] */
|
|
82
|
+
update = (_init_extra_flares(this), _init_update(this, true));
|
|
83
|
+
|
|
84
|
+
/** m_display (bool) [READWRITE, PERSIST] */
|
|
85
|
+
display = (_init_extra_update(this), _init_display(this, true));
|
|
86
|
+
|
|
87
|
+
/** m_isVisible (EveLensflare.h:95; ctor false, cpp:68) - runtime state,
|
|
88
|
+
* not persisted. */
|
|
89
|
+
isVisible = (_init_extra_display(this), false);
|
|
90
|
+
|
|
91
|
+
/** m_direction (EveLensflare.h:106) - zero until PrepareRender stamps
|
|
92
|
+
* Normalize(-position); the first-frame zero direction dots to 0, which
|
|
93
|
+
* counts as VISIBLE (the >= comparison) - deliberate Carbon behavior. */
|
|
94
|
+
direction = vec3.create();
|
|
95
|
+
|
|
96
|
+
/** m_sunSize (EveLensflare.h:107; ctor 0, cpp:71) - computed by Carbon's
|
|
97
|
+
* Update from the distance-to-center falloff (cpp:161-165); PrepareRender
|
|
98
|
+
* consumes it but does not produce it. Runtime state, not persisted. */
|
|
99
|
+
sunSize = 0;
|
|
100
|
+
|
|
101
|
+
/** m_occlusionOffset / m_backgroundOcclusionOffset (EveLensflare.h:140-141) -
|
|
102
|
+
* Tr2OcclusionBuffer slots this lensflare allocates on its first occlusion
|
|
103
|
+
* query (RunOcclusionQueries, cpp:330-337). null until then; Carbon's null
|
|
104
|
+
* case uploads 0. */
|
|
105
|
+
occlusionOffset = null;
|
|
106
|
+
backgroundOcclusionOffset = null;
|
|
107
|
+
|
|
108
|
+
/** m_directionVar: the global "LensflareFxDirectionScale" (cpp:72). */
|
|
109
|
+
#directionVar = _Tr2VariableStore.GlobalStore().RegisterVariable("LensflareFxDirectionScale", [0, 0, 0, 1]);
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* m_occScaleVar: the global "LensflareFxOccScale" (cpp:73), (1, 0, 0, 0)
|
|
113
|
+
* until the first Update. x and y carry the foreground and background slot
|
|
114
|
+
* bases as float BITS; the god rays read FlareOcclusionBuffer at y.
|
|
115
|
+
*/
|
|
116
|
+
#occScaleVar = _Tr2VariableStore.GlobalStore().RegisterVariable("LensflareFxOccScale", [1, 0, 0, 0]);
|
|
117
|
+
|
|
118
|
+
/** m_transform (EveLensflare.h:102; ctor identity, cpp:74) - stamped by
|
|
119
|
+
* PrepareRender, forwarded to the flare children as their parent. */
|
|
120
|
+
transform = mat4.create();
|
|
121
|
+
|
|
122
|
+
/** Carbon EveLensflare::Update (EveLensflare.cpp:145-182): position from the
|
|
123
|
+
* translation curve, the sun-size curve of very old magic numbers
|
|
124
|
+
* (1.5 / ln(d_AU + 2.71), 0.1495978707e12 metres per AU; no curve means
|
|
125
|
+
* sunSize 1, not the constructed 0), then curve sets and controllers.
|
|
126
|
+
* Then Carbon's occlusion upload (cpp:168-171): the slot bases bit-cast into
|
|
127
|
+
* the global LensflareFxOccScale. It is not a duplicate of the per-object
|
|
128
|
+
* indices GetPerObjectData ships: the flare mesh reads those, but the god
|
|
129
|
+
* rays read this GLOBAL, and until 2026-09-26 it was never written. The curve is
|
|
130
|
+
* called out-last (Update(simTime, position)) per the org convention -
|
|
131
|
+
* Carbon's is out-first. */
|
|
132
|
+
Update(realTime, simTime) {
|
|
133
|
+
if (!this.update) return;
|
|
134
|
+
if (this.translationCurve) {
|
|
135
|
+
this.translationCurve.Update(simTime, this.position);
|
|
136
|
+
const distanceToCenter = vec3.length(this.position) / 0.1495978707e12;
|
|
137
|
+
this.sunSize = 1.5 / Math.log(distanceToCenter + 2.71);
|
|
138
|
+
} else {
|
|
139
|
+
this.sunSize = 1;
|
|
149
140
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
* (a sun exactly perpendicular to the view IS visible), then every flare
|
|
154
|
-
* child updates its visibility under this lensflare's transform. NO display
|
|
155
|
-
* gate (the display || isVisible gate lives in GetRenderables, cpp:281).
|
|
156
|
-
* ONE-FRAME LATENCY is contract: within a Carbon frame this runs before
|
|
157
|
-
* PrepareRender, so the dot uses the PREVIOUS frame's direction and
|
|
158
|
-
* forwards the previous frame's transform - do not "fix" the order. Scene
|
|
159
|
-
* call site: EveSpaceScene.cpp:1462-1466 (sequential, single-lensflare). */
|
|
160
|
-
UpdateVisibility(updateContext) {
|
|
161
|
-
this.isVisible = false;
|
|
162
|
-
const frustum = updateContext?.GetFrustum?.() ?? updateContext?.frustum;
|
|
163
|
-
const viewDir = frustum?.viewDir ?? frustum?.m_viewDir;
|
|
164
|
-
const viewDotDir = viewDir ? vec3.dot(viewDir, this.direction) : 0;
|
|
165
|
-
this.isVisible = viewDotDir >= 0;
|
|
166
|
-
for (const flare of this.flares) {
|
|
167
|
-
flare?.UpdateVisibility(updateContext, this.transform);
|
|
168
|
-
}
|
|
141
|
+
this.#occScaleVar.SetValue([bitsAsFloat(this.occlusionOffset ?? 0), bitsAsFloat(this.backgroundOcclusionOffset ?? 0), 0, 0]);
|
|
142
|
+
for (const curveSet of this.curveSets) {
|
|
143
|
+
curveSet?.Update(realTime, simTime);
|
|
169
144
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
* Carbon RunOcclusionQueries (cpp:323-347): allocates this lensflare's
|
|
173
|
-
* foreground and background slots on first call - a new slot is Cleared to
|
|
174
|
-
* visibility 1.0 - then runs each foreground occluder's query into its
|
|
175
|
-
* counters.
|
|
176
|
-
*
|
|
177
|
-
* PARTIAL: EveOccluder.RunQuery (EveOccluder.cpp:150-185) is not ported, so
|
|
178
|
-
* the occluders do not run and the slots keep visibility 1.0 - the flare
|
|
179
|
-
* reads unoccluded. That is reported once rather than skipped silently.
|
|
180
|
-
*
|
|
181
|
-
* @param {Tr2RenderContext} renderContext The frame's context.
|
|
182
|
-
* @param {EveUpdateContext} _updateContext The occluders' context.
|
|
183
|
-
* @returns {void}
|
|
184
|
-
*/
|
|
185
|
-
RunOcclusionQueries(renderContext, _updateContext) {
|
|
186
|
-
if (!this.display) return;
|
|
187
|
-
const occlusionBuffer = _Tr2OcclusionBuffer.getInstance();
|
|
188
|
-
if (this.occlusionOffset === null) this.occlusionOffset = occlusionBuffer.AllocateOffset(renderContext);
|
|
189
|
-
if (this.backgroundOcclusionOffset === null) this.backgroundOcclusionOffset = occlusionBuffer.AllocateOffset(renderContext);
|
|
190
|
-
if (this.occluders.length) _EveLensflare.#WarnOccludersUnported();
|
|
145
|
+
for (const controller of this.controllers) {
|
|
146
|
+
controller?.Update(0.5);
|
|
191
147
|
}
|
|
148
|
+
}
|
|
192
149
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
150
|
+
/** Carbon EveLensflare::UpdateVisibility (EveLensflare.cpp:298-311): the
|
|
151
|
+
* viewDir dot test - visible iff dot(frustum.viewDir, direction) >= 0
|
|
152
|
+
* (a sun exactly perpendicular to the view IS visible), then every flare
|
|
153
|
+
* child updates its visibility under this lensflare's transform. NO display
|
|
154
|
+
* gate (the display || isVisible gate lives in GetRenderables, cpp:281).
|
|
155
|
+
* ONE-FRAME LATENCY is contract: within a Carbon frame this runs before
|
|
156
|
+
* PrepareRender, so the dot uses the PREVIOUS frame's direction and
|
|
157
|
+
* forwards the previous frame's transform - do not "fix" the order. Scene
|
|
158
|
+
* call site: EveSpaceScene.cpp:1462-1466 (sequential, single-lensflare). */
|
|
159
|
+
UpdateVisibility(updateContext) {
|
|
160
|
+
this.isVisible = false;
|
|
161
|
+
const frustum = updateContext?.GetFrustum?.() ?? updateContext?.frustum;
|
|
162
|
+
const viewDir = frustum?.viewDir ?? frustum?.m_viewDir;
|
|
163
|
+
const viewDotDir = viewDir ? vec3.dot(viewDir, this.direction) : 0;
|
|
164
|
+
this.isVisible = viewDotDir >= 0;
|
|
165
|
+
for (const flare of this.flares) {
|
|
166
|
+
flare?.UpdateVisibility(updateContext, this.transform);
|
|
209
167
|
}
|
|
168
|
+
}
|
|
210
169
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Carbon RunOcclusionQueries (cpp:323-347): allocates this lensflare's
|
|
172
|
+
* foreground and background slots on first call - a new slot is Cleared to
|
|
173
|
+
* visibility 1.0 - then runs each foreground occluder's query into its
|
|
174
|
+
* counters, with fog weight 1.
|
|
175
|
+
*
|
|
176
|
+
* @param {Tr2RenderContext} renderContext The frame's context.
|
|
177
|
+
* @param {EveUpdateContext} updateContext The occluders' context.
|
|
178
|
+
* @returns {void}
|
|
179
|
+
*/
|
|
180
|
+
RunOcclusionQueries(renderContext, updateContext) {
|
|
181
|
+
if (!this.display) return;
|
|
182
|
+
const occlusionBuffer = _Tr2OcclusionBuffer.getInstance();
|
|
183
|
+
if (this.occlusionOffset === null) this.occlusionOffset = occlusionBuffer.AllocateOffset(renderContext);
|
|
184
|
+
if (this.backgroundOcclusionOffset === null) this.backgroundOcclusionOffset = occlusionBuffer.AllocateOffset(renderContext);
|
|
185
|
+
let index = 0;
|
|
186
|
+
for (const occluder of this.occluders) {
|
|
187
|
+
occluder.RunQuery(renderContext, updateContext, this.transform, _Tr2OcclusionBuffer.getOccluderOffset(this.occlusionOffset, index++), 1);
|
|
217
188
|
}
|
|
189
|
+
}
|
|
218
190
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Carbon RunBackgroundOcclusionQueries (cpp:359-379): the background slot,
|
|
193
|
+
* then the background occluders. Carbon calls it from the background pass,
|
|
194
|
+
* only for scenes with planets (EveSpaceScene.cpp:2153-2170). Fog weight 0.
|
|
195
|
+
*
|
|
196
|
+
* @param {Tr2RenderContext} renderContext The frame's context.
|
|
197
|
+
* @param {EveUpdateContext} updateContext The occluders' context.
|
|
198
|
+
* @returns {void}
|
|
199
|
+
*/
|
|
200
|
+
RunBackgroundOcclusionQueries(renderContext, updateContext) {
|
|
201
|
+
if (!this.display) return;
|
|
202
|
+
if (this.backgroundOcclusionOffset === null) {
|
|
203
|
+
this.backgroundOcclusionOffset = _Tr2OcclusionBuffer.getInstance().AllocateOffset(renderContext);
|
|
230
204
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
for (const controller of this.controllers) controller?.Start();
|
|
205
|
+
let index = 0;
|
|
206
|
+
for (const occluder of this.backgroundOccluders) {
|
|
207
|
+
occluder.RunQuery(renderContext, updateContext, this.transform, _Tr2OcclusionBuffer.getOccluderOffset(this.backgroundOcclusionOffset, index++), 0);
|
|
235
208
|
}
|
|
209
|
+
}
|
|
236
210
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
*
|
|
245
|
-
* Carbon's row-vector `Transform( v, M )` over a row-major matrix is
|
|
246
|
-
* gl-matrix `transformMat4` over the same bytes.
|
|
247
|
-
*
|
|
248
|
-
* The render context is an ADDED argument: Carbon reads the view from
|
|
249
|
-
* Tr2Renderer::GetViewTransform, a static this runtime keeps on the context.
|
|
250
|
-
*
|
|
251
|
-
* @param {TriFrustum} frustum This frame's frustum.
|
|
252
|
-
* @param {Tr2RenderContext} renderContext The frame's context.
|
|
253
|
-
* @returns {void}
|
|
254
|
-
*/
|
|
255
|
-
PrepareRender(frustum, renderContext) {
|
|
256
|
-
if (!this.display) return;
|
|
257
|
-
if (vec3.squaredLength(this.position) === 0) vec3.normalize(this.direction, vec3.negate(prepareScratch, frustum.viewPos));else vec3.normalize(this.direction, vec3.negate(prepareScratch, this.position));
|
|
258
|
-
const cameraSpacePos = vec3.scaleAndAdd(vec3.create(), frustum.viewPos, frustum.viewDir, -this.cameraFactor);
|
|
259
|
-
mat4.arcFromForward(this.transform, vec3.negate(prepareScratch, this.direction));
|
|
260
|
-
this.transform[12] = cameraSpacePos[0];
|
|
261
|
-
this.transform[13] = cameraSpacePos[1];
|
|
262
|
-
this.transform[14] = cameraSpacePos[2];
|
|
263
|
-
this.transform[15] = 1;
|
|
264
|
-
this.#directionVar.SetValue([this.direction[0], this.direction[1], this.direction[2], this.sunSize]);
|
|
265
|
-
const direction = vec4.fromValues(this.direction[0], this.direction[1], this.direction[2], 0);
|
|
266
|
-
vec4.transformMat4(direction, direction, renderContext.GetViewTransform());
|
|
267
|
-
vec4.transformMat4(direction, direction, frustum.projectionMatrix);
|
|
268
|
-
direction[0] /= direction[3];
|
|
269
|
-
direction[1] /= direction[3];
|
|
270
|
-
const distanceToEdge = 1 - Math.min(1 - Math.abs(direction[0]), 1 - Math.abs(direction[1]));
|
|
271
|
-
const distanceToCenter = Math.hypot(direction[0], direction[1]);
|
|
272
|
-
const radialAngle = Math.atan2(direction[1], direction[0]) + Math.PI;
|
|
273
|
-
for (const curve of this.distanceToEdgeCurves) curve.UpdateValue(distanceToEdge);
|
|
274
|
-
for (const curve of this.distanceToCenterCurves) curve.UpdateValue(distanceToCenter);
|
|
275
|
-
for (const curve of this.radialAngleCurves) curve.UpdateValue(radialAngle);
|
|
276
|
-
for (const curve of this.xDistanceToCenter) curve.UpdateValue(direction[0] + 10);
|
|
277
|
-
for (const curve of this.yDistanceToCenter) curve.UpdateValue(direction[1] + 10);
|
|
278
|
-
for (const binding of this.bindings) binding.CopyValue();
|
|
279
|
-
}
|
|
211
|
+
/** Carbon method SetControllerVariable (MAP_METHOD_AND_WRAP). */
|
|
212
|
+
SetControllerVariable(name, value) {
|
|
213
|
+
const key = String(name);
|
|
214
|
+
const next = Number(value);
|
|
215
|
+
this.#controllerVariables.set(key, next);
|
|
216
|
+
for (const controller of this.controllers) controller?.SetVariable(key, next);
|
|
217
|
+
}
|
|
280
218
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
return renderables;
|
|
294
|
-
}
|
|
219
|
+
/**
|
|
220
|
+
* Carbon EveLensflare::HandleControllerEvent (cpp:497-503).
|
|
221
|
+
*
|
|
222
|
+
* MISSING UNTIL 2026-09-05. Carbon declares it beside SetControllerVariable
|
|
223
|
+
* and StartControllers, both of which were ported; this one was not, and the
|
|
224
|
+
* hedge at every call site meant a lens flare silently ignored every
|
|
225
|
+
* controller event rather than failing.
|
|
226
|
+
*/
|
|
227
|
+
HandleControllerEvent(name) {
|
|
228
|
+
const key = String(name);
|
|
229
|
+
for (const controller of this.controllers) controller?.HandleEvent(key);
|
|
230
|
+
}
|
|
295
231
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
}
|
|
232
|
+
/** Carbon method StartControllers (MAP_METHOD_AND_WRAP). */
|
|
233
|
+
StartControllers() {
|
|
234
|
+
for (const controller of this.controllers) controller?.Start();
|
|
235
|
+
}
|
|
302
236
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Carbon PrepareRender (cpp:192-266): the per-frame placement that needs
|
|
239
|
+
* this frame's frustum. The direction to the sun (from the camera when the
|
|
240
|
+
* flare has no position), a transform that turns the flare geometry toward
|
|
241
|
+
* it and parks it `cameraFactor` in front of the camera, the
|
|
242
|
+
* LensflareFxDirectionScale global, and the sun's screen position driving
|
|
243
|
+
* the edge, centre, angle and x/y curves before the bindings copy.
|
|
244
|
+
*
|
|
245
|
+
* Carbon's row-vector `Transform( v, M )` over a row-major matrix is
|
|
246
|
+
* gl-matrix `transformMat4` over the same bytes.
|
|
247
|
+
*
|
|
248
|
+
* The render context is an ADDED argument: Carbon reads the view from
|
|
249
|
+
* Tr2Renderer::GetViewTransform, a static this runtime keeps on the context.
|
|
250
|
+
*
|
|
251
|
+
* @param {TriFrustum} frustum This frame's frustum.
|
|
252
|
+
* @param {Tr2RenderContext} renderContext The frame's context.
|
|
253
|
+
* @returns {void}
|
|
254
|
+
*/
|
|
255
|
+
PrepareRender(frustum, renderContext) {
|
|
256
|
+
if (!this.display) return;
|
|
257
|
+
if (vec3.squaredLength(this.position) === 0) vec3.normalize(this.direction, vec3.negate(prepareScratch, frustum.viewPos));else vec3.normalize(this.direction, vec3.negate(prepareScratch, this.position));
|
|
258
|
+
const cameraSpacePos = vec3.scaleAndAdd(vec3.create(), frustum.viewPos, frustum.viewDir, -this.cameraFactor);
|
|
259
|
+
mat4.arcFromForward(this.transform, vec3.negate(prepareScratch, this.direction));
|
|
260
|
+
this.transform[12] = cameraSpacePos[0];
|
|
261
|
+
this.transform[13] = cameraSpacePos[1];
|
|
262
|
+
this.transform[14] = cameraSpacePos[2];
|
|
263
|
+
this.transform[15] = 1;
|
|
264
|
+
this.#directionVar.SetValue([this.direction[0], this.direction[1], this.direction[2], this.sunSize]);
|
|
265
|
+
const direction = vec4.fromValues(this.direction[0], this.direction[1], this.direction[2], 0);
|
|
266
|
+
vec4.transformMat4(direction, direction, renderContext.GetViewTransform());
|
|
267
|
+
vec4.transformMat4(direction, direction, frustum.projectionMatrix);
|
|
268
|
+
direction[0] /= direction[3];
|
|
269
|
+
direction[1] /= direction[3];
|
|
270
|
+
const distanceToEdge = 1 - Math.min(1 - Math.abs(direction[0]), 1 - Math.abs(direction[1]));
|
|
271
|
+
const distanceToCenter = Math.hypot(direction[0], direction[1]);
|
|
272
|
+
const radialAngle = Math.atan2(direction[1], direction[0]) + Math.PI;
|
|
273
|
+
for (const curve of this.distanceToEdgeCurves) curve.UpdateValue(distanceToEdge);
|
|
274
|
+
for (const curve of this.distanceToCenterCurves) curve.UpdateValue(distanceToCenter);
|
|
275
|
+
for (const curve of this.radialAngleCurves) curve.UpdateValue(radialAngle);
|
|
276
|
+
for (const curve of this.xDistanceToCenter) curve.UpdateValue(direction[0] + 10);
|
|
277
|
+
for (const curve of this.yDistanceToCenter) curve.UpdateValue(direction[1] + 10);
|
|
278
|
+
for (const binding of this.bindings) binding.CopyValue();
|
|
279
|
+
}
|
|
307
280
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
281
|
+
/**
|
|
282
|
+
* Carbon GetRenderables (cpp:278-296): nothing unless displayed and visible;
|
|
283
|
+
* each flare child's renderables, then this lensflare itself for its mesh.
|
|
284
|
+
*
|
|
285
|
+
* @param {TriFrustum} _frustum This frame's frustum (unused, as in Carbon).
|
|
286
|
+
* @param {Array} renderables Out: the renderables.
|
|
287
|
+
* @returns {Array} `renderables`.
|
|
288
|
+
*/
|
|
289
|
+
GetRenderables(_frustum, renderables = []) {
|
|
290
|
+
if (!this.display || !this.isVisible) return renderables;
|
|
291
|
+
for (const flare of this.flares) flare.GetRenderables(renderables, null);
|
|
292
|
+
if (this.mesh) renderables.push(this);
|
|
293
|
+
return renderables;
|
|
294
|
+
}
|
|
312
295
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
* with stages ["vs", "ps"]: one payload, same bytes bound to both slots
|
|
318
|
-
* (cpp:24-38). */
|
|
319
|
-
GetPerObjectData(accumulator) {
|
|
320
|
-
const data = accumulator.Alloc("EveLensflarePerObjectData");
|
|
321
|
-
data.Set("directionScale", [this.direction[0], this.direction[1], this.direction[2], this.sunSize]);
|
|
322
|
-
data.SetIndex("indices", 0, [this.occlusionOffset ?? 0]);
|
|
323
|
-
data.SetIndex("indices", 1, [this.backgroundOcclusionOffset ?? 0]);
|
|
324
|
-
return data;
|
|
296
|
+
/** Carbon EveLensflare::GetBatches delegates the selected mesh areas (cpp:381-387). */
|
|
297
|
+
GetBatches(batches, batchType, perObjectData, _reason) {
|
|
298
|
+
if (this.mesh) {
|
|
299
|
+
this.mesh.GetBatches?.(batches, this.mesh.GetAreas(batchType), perObjectData);
|
|
325
300
|
}
|
|
301
|
+
}
|
|
326
302
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
303
|
+
/** Carbon EveLensflare::HasTransparentBatches is always false (cpp:389-392). */
|
|
304
|
+
HasTransparentBatches() {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** Carbon EveLensflare::GetSortValue is the constant one (cpp:394-397). */
|
|
309
|
+
GetSortValue() {
|
|
310
|
+
return 1;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** Carbon EveLensflare::GetPerObjectData (cpp:399-410): directionScale =
|
|
314
|
+
* (direction, sunSize); indices[0]/[1] from the optional occlusion offsets
|
|
315
|
+
* (null uploads 0). indices[2] and [3] are NEVER written in Carbon - the
|
|
316
|
+
* per-element writes keep that arena-garbage parity. The struct registers
|
|
317
|
+
* with stages ["vs", "ps"]: one payload, same bytes bound to both slots
|
|
318
|
+
* (cpp:24-38). */
|
|
319
|
+
GetPerObjectData(accumulator) {
|
|
320
|
+
const data = accumulator.Alloc("EveLensflarePerObjectData");
|
|
321
|
+
data.Set("directionScale", [this.direction[0], this.direction[1], this.direction[2], this.sunSize]);
|
|
322
|
+
data.SetIndex("indices", 0, [this.occlusionOffset ?? 0]);
|
|
323
|
+
data.SetIndex("indices", 1, [this.backgroundOcclusionOffset ?? 0]);
|
|
324
|
+
return data;
|
|
325
|
+
}
|
|
342
326
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
327
|
+
/**
|
|
328
|
+
* Returns this lensflare's occlusion-buffer slots. Carbon holds them as
|
|
329
|
+
* Tr2OcclusionBuffer::Offset shared_ptrs whose deleter frees the slot when
|
|
330
|
+
* the lensflare is destroyed (EveOccluder.cpp:36, 70-74); JavaScript has no
|
|
331
|
+
* destructor, so the owner removing a lensflare calls this.
|
|
332
|
+
*
|
|
333
|
+
* @returns {void}
|
|
334
|
+
*/
|
|
335
|
+
Destroy() {
|
|
336
|
+
const occlusionBuffer = _Tr2OcclusionBuffer.getInstance();
|
|
337
|
+
occlusionBuffer.DestroyOffset(this.occlusionOffset);
|
|
338
|
+
occlusionBuffer.DestroyOffset(this.backgroundOcclusionOffset);
|
|
339
|
+
this.occlusionOffset = null;
|
|
340
|
+
this.backgroundOcclusionOffset = null;
|
|
349
341
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
super(_EveLensflare), _initClass();
|
|
342
|
+
static {
|
|
343
|
+
_initClass();
|
|
353
344
|
}
|
|
354
|
-
}
|
|
345
|
+
}
|
|
355
346
|
|
|
356
347
|
export { _EveLensflare as EveLensflare };
|
|
357
348
|
//# sourceMappingURL=EveLensflare.js.map
|