@babylonjs/core 5.17.1 → 5.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Debug/debugLayer.d.ts +36 -0
- package/Debug/debugLayer.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSource.d.ts +1 -1
- package/DeviceInput/InputDevices/deviceSource.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSourceManager.d.ts +1 -1
- package/DeviceInput/InputDevices/deviceSourceManager.js +1 -1
- package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
- package/DeviceInput/{Helpers/eventFactory.d.ts → eventFactory.d.ts} +4 -4
- package/DeviceInput/{Helpers/eventFactory.js → eventFactory.js} +2 -2
- package/DeviceInput/eventFactory.js.map +1 -0
- package/DeviceInput/{InputDevices/inputInterfaces.d.ts → inputInterfaces.d.ts} +2 -2
- package/DeviceInput/{InputDevices/inputInterfaces.js → inputInterfaces.js} +0 -0
- package/DeviceInput/inputInterfaces.js.map +1 -0
- package/DeviceInput/{InputDevices/internalDeviceSourceManager.d.ts → internalDeviceSourceManager.d.ts} +7 -7
- package/DeviceInput/{InputDevices/internalDeviceSourceManager.js → internalDeviceSourceManager.js} +2 -2
- package/DeviceInput/internalDeviceSourceManager.js.map +1 -0
- package/DeviceInput/{InputDevices/nativeDeviceInputSystem.d.ts → nativeDeviceInputSystem.d.ts} +2 -2
- package/DeviceInput/{InputDevices/nativeDeviceInputSystem.js → nativeDeviceInputSystem.js} +2 -2
- package/DeviceInput/nativeDeviceInputSystem.js.map +1 -0
- package/DeviceInput/{InputDevices/webDeviceInputSystem.d.ts → webDeviceInputSystem.d.ts} +3 -3
- package/DeviceInput/{InputDevices/webDeviceInputSystem.js → webDeviceInputSystem.js} +4 -4
- package/DeviceInput/webDeviceInputSystem.js.map +1 -0
- package/Engines/Extensions/engine.query.js +5 -1
- package/Engines/Extensions/engine.query.js.map +1 -1
- package/Engines/Extensions/engine.transformFeedback.js +5 -1
- package/Engines/Extensions/engine.transformFeedback.js.map +1 -1
- package/Engines/Extensions/engine.views.d.ts +13 -0
- package/Engines/Extensions/engine.views.js +16 -1
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +1 -1
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/engine.d.ts +15 -240
- package/Engines/engineFeatures.d.ts +2 -0
- package/Engines/engineFeatures.js.map +1 -1
- package/Engines/nativeEngine.js +1 -0
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +1 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +1 -1
- package/Engines/thinEngine.js +14 -4
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/axisDragGizmo.d.ts +31 -9
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/axisScaleGizmo.d.ts +46 -14
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +94 -19
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/cameraGizmo.d.ts +23 -6
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/gizmo.d.ts +48 -6
- package/Gizmos/gizmo.js.map +1 -1
- package/Gizmos/gizmoManager.d.ts +25 -17
- package/Gizmos/gizmoManager.js.map +1 -1
- package/Gizmos/lightGizmo.d.ts +25 -8
- package/Gizmos/lightGizmo.js.map +1 -1
- package/Gizmos/planeDragGizmo.d.ts +30 -9
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.d.ts +45 -15
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.d.ts +53 -17
- package/Gizmos/positionGizmo.js +1 -1
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.d.ts +35 -10
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.d.ts +49 -18
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +16 -4
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.d.ts +39 -0
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +97 -0
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -0
- package/Materials/Node/Blocks/Fragment/index.d.ts +1 -0
- package/Materials/Node/Blocks/Fragment/index.js +1 -0
- package/Materials/Node/Blocks/Fragment/index.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.d.ts +18 -0
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +85 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +6 -0
- package/Materials/Node/nodeMaterial.js +11 -0
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +5 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +3 -0
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.js +9 -5
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Maths/math.vector.d.ts +134 -8
- package/Maths/math.vector.js +168 -36
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Compression/dracoCompression.js +1 -1
- package/Meshes/Compression/dracoCompression.js.map +1 -1
- package/Meshes/groundMesh.js +1 -1
- package/Meshes/groundMesh.js.map +1 -1
- package/Meshes/mesh.js +1 -0
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/transformNode.js +1 -0
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/assetsManager.d.ts +9 -0
- package/Misc/assetsManager.js +3 -1
- package/Misc/assetsManager.js.map +1 -1
- package/Misc/basis.js +10 -4
- package/Misc/basis.js.map +1 -1
- package/Misc/computePressure.d.ts +9 -3
- package/Misc/computePressure.js +13 -5
- package/Misc/computePressure.js.map +1 -1
- package/Misc/fileTools.js +2 -2
- package/Misc/fileTools.js.map +1 -1
- package/Misc/iInspectable.d.ts +12 -2
- package/Misc/iInspectable.js +4 -0
- package/Misc/iInspectable.js.map +1 -1
- package/Misc/khronosTextureContainer2.js +1 -1
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/sceneSerializer.js +1 -1
- package/Misc/sceneSerializer.js.map +1 -1
- package/Misc/tools.d.ts +2 -2
- package/Misc/tools.js +4 -1
- package/Misc/tools.js.map +1 -1
- package/Offline/database.js +6 -8
- package/Offline/database.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +1 -0
- package/Particles/solidParticleSystem.js +4 -1
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Physics/Plugins/ammoJSPlugin.d.ts +2 -2
- package/Physics/Plugins/ammoJSPlugin.js +29 -29
- package/Physics/Plugins/ammoJSPlugin.js.map +1 -1
- package/Physics/Plugins/cannonJSPlugin.d.ts +2 -2
- package/Physics/Plugins/cannonJSPlugin.js +26 -26
- package/Physics/Plugins/cannonJSPlugin.js.map +1 -1
- package/Physics/Plugins/oimoJSPlugin.js +9 -11
- package/Physics/Plugins/oimoJSPlugin.js.map +1 -1
- package/Physics/physicsImpostor.d.ts +6 -6
- package/Physics/physicsImpostor.js +15 -8
- package/Physics/physicsImpostor.js.map +1 -1
- package/Shaders/sprites.fragment.js +1 -1
- package/Shaders/sprites.fragment.js.map +1 -1
- package/Sprites/spriteRenderer.js +1 -1
- package/Sprites/spriteRenderer.js.map +1 -1
- package/XR/webXRDefaultExperience.d.ts +10 -0
- package/XR/webXRDefaultExperience.js +2 -12
- package/XR/webXRDefaultExperience.js.map +1 -1
- package/XR/webXRExperienceHelper.js +12 -12
- package/XR/webXRExperienceHelper.js.map +1 -1
- package/node.d.ts +2 -0
- package/node.js +2 -0
- package/node.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +1 -1
- package/scene.js +5 -3
- package/scene.js.map +1 -1
- package/DeviceInput/Helpers/eventFactory.js.map +0 -1
- package/DeviceInput/InputDevices/inputInterfaces.js.map +0 -1
- package/DeviceInput/InputDevices/internalDeviceSourceManager.js.map +0 -1
- package/DeviceInput/InputDevices/nativeDeviceInputSystem.js.map +0 -1
- package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../lts/core/generated/Materials/Node/Blocks/Fragment/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC","sourcesContent":["export * from \"./fragmentOutputBlock\";\r\nexport * from \"./imageProcessingBlock\";\r\nexport * from \"./perturbNormalBlock\";\r\nexport * from \"./discardBlock\";\r\nexport * from \"./frontFacingBlock\";\r\nexport * from \"./derivativeBlock\";\r\nexport * from \"./fragCoordBlock\";\r\nexport * from \"./screenSizeBlock\";\r\nexport * from \"./screenSpaceBlock\";\r\nexport * from \"./twirlBlock\";\r\nexport * from \"./TBNBlock\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../lts/core/generated/Materials/Node/Blocks/Fragment/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC","sourcesContent":["export * from \"./fragmentOutputBlock\";\r\nexport * from \"./imageProcessingBlock\";\r\nexport * from \"./perturbNormalBlock\";\r\nexport * from \"./discardBlock\";\r\nexport * from \"./frontFacingBlock\";\r\nexport * from \"./derivativeBlock\";\r\nexport * from \"./fragCoordBlock\";\r\nexport * from \"./screenSizeBlock\";\r\nexport * from \"./screenSpaceBlock\";\r\nexport * from \"./twirlBlock\";\r\nexport * from \"./TBNBlock\";\r\nexport * from \"./heightToNormalBlock\";\r\n"]}
|
|
@@ -14,6 +14,8 @@ import type { AbstractMesh } from "../../../../Meshes/abstractMesh";
|
|
|
14
14
|
export declare class LightInformationBlock extends NodeMaterialBlock {
|
|
15
15
|
private _lightDataUniformName;
|
|
16
16
|
private _lightColorUniformName;
|
|
17
|
+
private _lightShadowUniformName;
|
|
18
|
+
private _lightShadowExtraUniformName;
|
|
17
19
|
private _lightTypeDefineName;
|
|
18
20
|
private _forcePrepareDefines;
|
|
19
21
|
/**
|
|
@@ -46,6 +48,22 @@ export declare class LightInformationBlock extends NodeMaterialBlock {
|
|
|
46
48
|
* Gets the direction output component
|
|
47
49
|
*/
|
|
48
50
|
get intensity(): NodeMaterialConnectionPoint;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the shadow bias output component
|
|
53
|
+
*/
|
|
54
|
+
get shadowBias(): NodeMaterialConnectionPoint;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the shadow normal bias output component
|
|
57
|
+
*/
|
|
58
|
+
get shadowNormalBias(): NodeMaterialConnectionPoint;
|
|
59
|
+
/**
|
|
60
|
+
* Gets the shadow depth scale component
|
|
61
|
+
*/
|
|
62
|
+
get shadowDepthScale(): NodeMaterialConnectionPoint;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the shadow depth range component
|
|
65
|
+
*/
|
|
66
|
+
get shadowDepthRange(): NodeMaterialConnectionPoint;
|
|
49
67
|
bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
|
|
50
68
|
prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
|
|
51
69
|
protected _buildBlock(state: NodeMaterialBuildState): this;
|
|
@@ -19,6 +19,10 @@ var LightInformationBlock = /** @class */ (function (_super) {
|
|
|
19
19
|
_this.registerOutput("direction", NodeMaterialBlockConnectionPointTypes.Vector3);
|
|
20
20
|
_this.registerOutput("color", NodeMaterialBlockConnectionPointTypes.Color3);
|
|
21
21
|
_this.registerOutput("intensity", NodeMaterialBlockConnectionPointTypes.Float);
|
|
22
|
+
_this.registerOutput("shadowBias", NodeMaterialBlockConnectionPointTypes.Float);
|
|
23
|
+
_this.registerOutput("shadowNormalBias", NodeMaterialBlockConnectionPointTypes.Float);
|
|
24
|
+
_this.registerOutput("shadowDepthScale", NodeMaterialBlockConnectionPointTypes.Float);
|
|
25
|
+
_this.registerOutput("shadowDepthRange", NodeMaterialBlockConnectionPointTypes.Vector2);
|
|
22
26
|
return _this;
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
@@ -68,11 +72,51 @@ var LightInformationBlock = /** @class */ (function (_super) {
|
|
|
68
72
|
enumerable: false,
|
|
69
73
|
configurable: true
|
|
70
74
|
});
|
|
75
|
+
Object.defineProperty(LightInformationBlock.prototype, "shadowBias", {
|
|
76
|
+
/**
|
|
77
|
+
* Gets the shadow bias output component
|
|
78
|
+
*/
|
|
79
|
+
get: function () {
|
|
80
|
+
return this._outputs[3];
|
|
81
|
+
},
|
|
82
|
+
enumerable: false,
|
|
83
|
+
configurable: true
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(LightInformationBlock.prototype, "shadowNormalBias", {
|
|
86
|
+
/**
|
|
87
|
+
* Gets the shadow normal bias output component
|
|
88
|
+
*/
|
|
89
|
+
get: function () {
|
|
90
|
+
return this._outputs[4];
|
|
91
|
+
},
|
|
92
|
+
enumerable: false,
|
|
93
|
+
configurable: true
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(LightInformationBlock.prototype, "shadowDepthScale", {
|
|
96
|
+
/**
|
|
97
|
+
* Gets the shadow depth scale component
|
|
98
|
+
*/
|
|
99
|
+
get: function () {
|
|
100
|
+
return this._outputs[5];
|
|
101
|
+
},
|
|
102
|
+
enumerable: false,
|
|
103
|
+
configurable: true
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(LightInformationBlock.prototype, "shadowDepthRange", {
|
|
106
|
+
/**
|
|
107
|
+
* Gets the shadow depth range component
|
|
108
|
+
*/
|
|
109
|
+
get: function () {
|
|
110
|
+
return this._outputs[6];
|
|
111
|
+
},
|
|
112
|
+
enumerable: false,
|
|
113
|
+
configurable: true
|
|
114
|
+
});
|
|
71
115
|
LightInformationBlock.prototype.bind = function (effect, nodeMaterial, mesh) {
|
|
72
116
|
if (!mesh) {
|
|
73
117
|
return;
|
|
74
118
|
}
|
|
75
|
-
if (this.light && this.light.isDisposed) {
|
|
119
|
+
if (this.light && this.light.isDisposed()) {
|
|
76
120
|
this.light = null;
|
|
77
121
|
}
|
|
78
122
|
var light = this.light;
|
|
@@ -88,6 +132,24 @@ var LightInformationBlock = /** @class */ (function (_super) {
|
|
|
88
132
|
}
|
|
89
133
|
light.transferToNodeMaterialEffect(effect, this._lightDataUniformName);
|
|
90
134
|
effect.setColor4(this._lightColorUniformName, light.diffuse, light.intensity);
|
|
135
|
+
var generator = light.getShadowGenerator();
|
|
136
|
+
if (this.shadowBias.hasEndpoints || this.shadowNormalBias.hasEndpoints || this.shadowDepthScale.hasEndpoints) {
|
|
137
|
+
if (generator) {
|
|
138
|
+
effect.setFloat3(this._lightShadowUniformName, generator.bias, generator.normalBias, generator.depthScale);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
effect.setFloat3(this._lightShadowUniformName, 0, 0, 0);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (this.shadowDepthRange) {
|
|
145
|
+
if (generator && scene.activeCamera) {
|
|
146
|
+
var shadowLight = light;
|
|
147
|
+
effect.setFloat2(this._lightShadowExtraUniformName, shadowLight.getDepthMinZ(scene.activeCamera), shadowLight.getDepthMinZ(scene.activeCamera) + shadowLight.getDepthMaxZ(scene.activeCamera));
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
effect.setFloat2(this._lightShadowExtraUniformName, 0, 0);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
91
153
|
};
|
|
92
154
|
LightInformationBlock.prototype.prepareDefines = function (mesh, nodeMaterial, defines) {
|
|
93
155
|
if (!defines._areLightsDirty && !this._forcePrepareDefines) {
|
|
@@ -104,8 +166,14 @@ var LightInformationBlock = /** @class */ (function (_super) {
|
|
|
104
166
|
var direction = this.direction;
|
|
105
167
|
var color = this.color;
|
|
106
168
|
var intensity = this.intensity;
|
|
169
|
+
var shadowBias = this.shadowBias;
|
|
170
|
+
var shadowNormalBias = this.shadowNormalBias;
|
|
171
|
+
var shadowDepthScale = this.shadowDepthScale;
|
|
172
|
+
var shadowDepthRange = this.shadowDepthRange;
|
|
107
173
|
this._lightDataUniformName = state._getFreeVariableName("lightData");
|
|
108
174
|
this._lightColorUniformName = state._getFreeVariableName("lightColor");
|
|
175
|
+
this._lightShadowUniformName = state._getFreeVariableName("shadowData");
|
|
176
|
+
this._lightShadowExtraUniformName = state._getFreeVariableName("shadowExtraData");
|
|
109
177
|
this._lightTypeDefineName = state._getFreeDefineName("LIGHTPOINTTYPE");
|
|
110
178
|
state._emitUniformFromString(this._lightDataUniformName, "vec3");
|
|
111
179
|
state._emitUniformFromString(this._lightColorUniformName, "vec4");
|
|
@@ -116,6 +184,22 @@ var LightInformationBlock = /** @class */ (function (_super) {
|
|
|
116
184
|
state.compilationString += "#endif\r\n";
|
|
117
185
|
state.compilationString += this._declareOutput(color, state) + " = ".concat(this._lightColorUniformName, ".rgb;\r\n");
|
|
118
186
|
state.compilationString += this._declareOutput(intensity, state) + " = ".concat(this._lightColorUniformName, ".a;\r\n");
|
|
187
|
+
if (shadowBias.hasEndpoints || shadowNormalBias.hasEndpoints || shadowDepthScale.hasEndpoints) {
|
|
188
|
+
state._emitUniformFromString(this._lightShadowUniformName, "vec3");
|
|
189
|
+
if (shadowBias.hasEndpoints) {
|
|
190
|
+
state.compilationString += this._declareOutput(shadowBias, state) + " = ".concat(this._lightShadowUniformName, ".x;\r\n");
|
|
191
|
+
}
|
|
192
|
+
if (shadowNormalBias.hasEndpoints) {
|
|
193
|
+
state.compilationString += this._declareOutput(shadowNormalBias, state) + " = ".concat(this._lightShadowUniformName, ".y;\r\n");
|
|
194
|
+
}
|
|
195
|
+
if (shadowDepthScale.hasEndpoints) {
|
|
196
|
+
state.compilationString += this._declareOutput(shadowDepthScale, state) + " = ".concat(this._lightShadowUniformName, ".z;\r\n");
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (shadowDepthRange.hasEndpoints) {
|
|
200
|
+
state._emitUniformFromString(this._lightShadowExtraUniformName, "vec2");
|
|
201
|
+
state.compilationString += this._declareOutput(shadowDepthRange, state) + " = ".concat(this._lightShadowUniformName, ";\r\n");
|
|
202
|
+
}
|
|
119
203
|
return this;
|
|
120
204
|
};
|
|
121
205
|
LightInformationBlock.prototype.serialize = function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lightInformationBlock.js","sourceRoot":"","sources":["../../../../../../../../lts/core/generated/Materials/Node/Blocks/Vertex/lightInformationBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAG1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,C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,IAAI,CAAC,qBAAqB,UAAO,CAAC;QAC3G,KAAK,CAAC,iBAAiB,IAAI,YAAY,CAAC;QAExC,KAAK,CAAC,iBAAiB,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,aAAM,IAAI,CAAC,sBAAsB,cAAW,CAAC;QAC5G,KAAK,CAAC,iBAAiB,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,aAAM,IAAI,CAAC,sBAAsB,YAAS,CAAC;QAE9G,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,yCAAS,GAAhB;QACI,IAAM,mBAAmB,GAAG,iBAAM,SAAS,WAAE,CAAC;QAE9C,IAAI,IAAI,CAAC,KAAK,EAAE;YACZ,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;SAC/C;QAED,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,4CAAY,GAAnB,UAAoB,mBAAwB,EAAE,KAAY,EAAE,OAAe;QACvE,iBAAM,YAAY,YAAC,mBAAmB,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAExD,IAAI,mBAAmB,CAAC,OAAO,EAAE;YAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;SAChE;IACL,CAAC;IACL,4BAAC;AAAD,CAAC,AAjJD,CAA2C,iBAAiB,GAiJ3D;;AAED,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { Nullable } from \"../../../../types\";\r\nimport type { Scene } from \"../../../../scene\";\r\nimport type { Effect } from \"../../../effect\";\r\nimport type { NodeMaterial, NodeMaterialDefines } from \"../../nodeMaterial\";\r\nimport type { Mesh } from \"../../../../Meshes/mesh\";\r\nimport type { Light } from \"../../../../Lights/light\";\r\nimport { PointLight } from \"../../../../Lights/pointLight\";\r\nimport type { AbstractMesh } from \"../../../../Meshes/abstractMesh\";\r\n/**\r\n * Block used to get data information from a light\r\n */\r\nexport class LightInformationBlock extends NodeMaterialBlock {\r\n private _lightDataUniformName: string;\r\n private _lightColorUniformName: string;\r\n private _lightTypeDefineName: string;\r\n private _forcePrepareDefines: boolean;\r\n\r\n /**\r\n * Gets or sets the light associated with this block\r\n */\r\n public light: Nullable<Light>;\r\n\r\n /**\r\n * Creates a new LightInformationBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Vertex);\r\n\r\n this.registerInput(\"worldPosition\", NodeMaterialBlockConnectionPointTypes.Vector4, false, NodeMaterialBlockTargets.Vertex);\r\n this.registerOutput(\"direction\", NodeMaterialBlockConnectionPointTypes.Vector3);\r\n this.registerOutput(\"color\", NodeMaterialBlockConnectionPointTypes.Color3);\r\n this.registerOutput(\"intensity\", NodeMaterialBlockConnectionPointTypes.Float);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"LightInformationBlock\";\r\n }\r\n\r\n /**\r\n * Gets the world position input component\r\n */\r\n public get worldPosition(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction output component\r\n */\r\n public get direction(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction output component\r\n */\r\n public get color(): NodeMaterialConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction output component\r\n */\r\n public get intensity(): NodeMaterialConnectionPoint {\r\n return this._outputs[2];\r\n }\r\n\r\n public bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh) {\r\n if (!mesh) {\r\n return;\r\n }\r\n\r\n if (this.light && this.light.isDisposed) {\r\n this.light = null;\r\n }\r\n\r\n let light = this.light;\r\n const scene = nodeMaterial.getScene();\r\n\r\n if (!light && scene.lights.length) {\r\n light = this.light = scene.lights[0];\r\n this._forcePrepareDefines = true;\r\n }\r\n\r\n if (!light || !light.isEnabled) {\r\n effect.setFloat3(this._lightDataUniformName, 0, 0, 0);\r\n effect.setFloat4(this._lightColorUniformName, 0, 0, 0, 0);\r\n return;\r\n }\r\n\r\n light.transferToNodeMaterialEffect(effect, this._lightDataUniformName);\r\n\r\n effect.setColor4(this._lightColorUniformName, light.diffuse, light.intensity);\r\n }\r\n\r\n public prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines) {\r\n if (!defines._areLightsDirty && !this._forcePrepareDefines) {\r\n return;\r\n }\r\n\r\n this._forcePrepareDefines = false;\r\n\r\n const light = this.light;\r\n defines.setValue(this._lightTypeDefineName, light && light instanceof PointLight ? true : false, true);\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n state.sharedData.bindableBlocks.push(this);\r\n state.sharedData.blocksWithDefines.push(this);\r\n\r\n const direction = this.direction;\r\n const color = this.color;\r\n const intensity = this.intensity;\r\n\r\n this._lightDataUniformName = state._getFreeVariableName(\"lightData\");\r\n this._lightColorUniformName = state._getFreeVariableName(\"lightColor\");\r\n this._lightTypeDefineName = state._getFreeDefineName(\"LIGHTPOINTTYPE\");\r\n\r\n state._emitUniformFromString(this._lightDataUniformName, \"vec3\");\r\n state._emitUniformFromString(this._lightColorUniformName, \"vec4\");\r\n\r\n state.compilationString += `#ifdef ${this._lightTypeDefineName}\\r\\n`;\r\n state.compilationString += this._declareOutput(direction, state) + ` = normalize(${this.worldPosition.associatedVariableName}.xyz - ${this._lightDataUniformName});\\r\\n`;\r\n state.compilationString += `#else\\r\\n`;\r\n state.compilationString += this._declareOutput(direction, state) + ` = ${this._lightDataUniformName};\\r\\n`;\r\n state.compilationString += `#endif\\r\\n`;\r\n\r\n state.compilationString += this._declareOutput(color, state) + ` = ${this._lightColorUniformName}.rgb;\\r\\n`;\r\n state.compilationString += this._declareOutput(intensity, state) + ` = ${this._lightColorUniformName}.a;\\r\\n`;\r\n\r\n return this;\r\n }\r\n\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n if (this.light) {\r\n serializationObject.lightId = this.light.id;\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {\r\n super._deserialize(serializationObject, scene, rootUrl);\r\n\r\n if (serializationObject.lightId) {\r\n this.light = scene.getLightById(serializationObject.lightId);\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.LightInformationBlock\", LightInformationBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"lightInformationBlock.js","sourceRoot":"","sources":["../../../../../../../../lts/core/generated/Materials/Node/Blocks/Vertex/lightInformationBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAG1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAO3D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAK3D;;GAEG;AACH;IAA2C,yCAAiB;IAaxD;;;OAGG;IACH,+BAAmB,IAAY;QAA/B,YACI,kBAAM,IAAI,EAAE,wBAAwB,CAAC,MAAM,CAAC,SAU/C;QARG,KAAI,CAAC,aAAa,CAAC,eAAe,EAAE,qCA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AAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { Nullable } from \"../../../../types\";\r\nimport type { Scene } from \"../../../../scene\";\r\nimport type { Effect } from \"../../../effect\";\r\nimport type { NodeMaterial, NodeMaterialDefines } from \"../../nodeMaterial\";\r\nimport type { Mesh } from \"../../../../Meshes/mesh\";\r\nimport type { Light } from \"../../../../Lights/light\";\r\nimport { PointLight } from \"../../../../Lights/pointLight\";\r\nimport type { AbstractMesh } from \"../../../../Meshes/abstractMesh\";\r\nimport type { ShadowGenerator } from \"../../../../Lights/Shadows/shadowGenerator\";\r\nimport type { ShadowLight } from \"../../../../Lights\";\r\n\r\n/**\r\n * Block used to get data information from a light\r\n */\r\nexport class LightInformationBlock extends NodeMaterialBlock {\r\n private _lightDataUniformName: string;\r\n private _lightColorUniformName: string;\r\n private _lightShadowUniformName: string;\r\n private _lightShadowExtraUniformName: string;\r\n private _lightTypeDefineName: string;\r\n private _forcePrepareDefines: boolean;\r\n\r\n /**\r\n * Gets or sets the light associated with this block\r\n */\r\n public light: Nullable<Light>;\r\n\r\n /**\r\n * Creates a new LightInformationBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Vertex);\r\n\r\n this.registerInput(\"worldPosition\", NodeMaterialBlockConnectionPointTypes.Vector4, false, NodeMaterialBlockTargets.Vertex);\r\n this.registerOutput(\"direction\", NodeMaterialBlockConnectionPointTypes.Vector3);\r\n this.registerOutput(\"color\", NodeMaterialBlockConnectionPointTypes.Color3);\r\n this.registerOutput(\"intensity\", NodeMaterialBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"shadowBias\", NodeMaterialBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"shadowNormalBias\", NodeMaterialBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"shadowDepthScale\", NodeMaterialBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"shadowDepthRange\", NodeMaterialBlockConnectionPointTypes.Vector2);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"LightInformationBlock\";\r\n }\r\n\r\n /**\r\n * Gets the world position input component\r\n */\r\n public get worldPosition(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction output component\r\n */\r\n public get direction(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction output component\r\n */\r\n public get color(): NodeMaterialConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction output component\r\n */\r\n public get intensity(): NodeMaterialConnectionPoint {\r\n return this._outputs[2];\r\n }\r\n\r\n /**\r\n * Gets the shadow bias output component\r\n */\r\n public get shadowBias(): NodeMaterialConnectionPoint {\r\n return this._outputs[3];\r\n }\r\n\r\n /**\r\n * Gets the shadow normal bias output component\r\n */\r\n public get shadowNormalBias(): NodeMaterialConnectionPoint {\r\n return this._outputs[4];\r\n }\r\n\r\n /**\r\n * Gets the shadow depth scale component\r\n */\r\n public get shadowDepthScale(): NodeMaterialConnectionPoint {\r\n return this._outputs[5];\r\n }\r\n\r\n /**\r\n * Gets the shadow depth range component\r\n */\r\n public get shadowDepthRange(): NodeMaterialConnectionPoint {\r\n return this._outputs[6];\r\n }\r\n\r\n public bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh) {\r\n if (!mesh) {\r\n return;\r\n }\r\n\r\n if (this.light && this.light.isDisposed()) {\r\n this.light = null;\r\n }\r\n\r\n let light = this.light;\r\n const scene = nodeMaterial.getScene();\r\n\r\n if (!light && scene.lights.length) {\r\n light = this.light = scene.lights[0];\r\n this._forcePrepareDefines = true;\r\n }\r\n\r\n if (!light || !light.isEnabled) {\r\n effect.setFloat3(this._lightDataUniformName, 0, 0, 0);\r\n effect.setFloat4(this._lightColorUniformName, 0, 0, 0, 0);\r\n return;\r\n }\r\n\r\n light.transferToNodeMaterialEffect(effect, this._lightDataUniformName);\r\n\r\n effect.setColor4(this._lightColorUniformName, light.diffuse, light.intensity);\r\n\r\n const generator = light.getShadowGenerator() as ShadowGenerator;\r\n if (this.shadowBias.hasEndpoints || this.shadowNormalBias.hasEndpoints || this.shadowDepthScale.hasEndpoints) {\r\n if (generator) {\r\n effect.setFloat3(this._lightShadowUniformName, generator.bias, generator.normalBias, generator.depthScale);\r\n } else {\r\n effect.setFloat3(this._lightShadowUniformName, 0, 0, 0);\r\n }\r\n }\r\n\r\n if (this.shadowDepthRange) {\r\n if (generator && scene.activeCamera) {\r\n const shadowLight = light as ShadowLight;\r\n effect.setFloat2(\r\n this._lightShadowExtraUniformName,\r\n shadowLight.getDepthMinZ(scene.activeCamera),\r\n shadowLight.getDepthMinZ(scene.activeCamera) + shadowLight.getDepthMaxZ(scene.activeCamera)\r\n );\r\n } else {\r\n effect.setFloat2(this._lightShadowExtraUniformName, 0, 0);\r\n }\r\n }\r\n }\r\n\r\n public prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines) {\r\n if (!defines._areLightsDirty && !this._forcePrepareDefines) {\r\n return;\r\n }\r\n\r\n this._forcePrepareDefines = false;\r\n\r\n const light = this.light;\r\n defines.setValue(this._lightTypeDefineName, light && light instanceof PointLight ? true : false, true);\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n state.sharedData.bindableBlocks.push(this);\r\n state.sharedData.blocksWithDefines.push(this);\r\n\r\n const direction = this.direction;\r\n const color = this.color;\r\n const intensity = this.intensity;\r\n const shadowBias = this.shadowBias;\r\n const shadowNormalBias = this.shadowNormalBias;\r\n const shadowDepthScale = this.shadowDepthScale;\r\n const shadowDepthRange = this.shadowDepthRange;\r\n\r\n this._lightDataUniformName = state._getFreeVariableName(\"lightData\");\r\n this._lightColorUniformName = state._getFreeVariableName(\"lightColor\");\r\n this._lightShadowUniformName = state._getFreeVariableName(\"shadowData\");\r\n this._lightShadowExtraUniformName = state._getFreeVariableName(\"shadowExtraData\");\r\n this._lightTypeDefineName = state._getFreeDefineName(\"LIGHTPOINTTYPE\");\r\n\r\n state._emitUniformFromString(this._lightDataUniformName, \"vec3\");\r\n state._emitUniformFromString(this._lightColorUniformName, \"vec4\");\r\n\r\n state.compilationString += `#ifdef ${this._lightTypeDefineName}\\r\\n`;\r\n state.compilationString += this._declareOutput(direction, state) + ` = normalize(${this.worldPosition.associatedVariableName}.xyz - ${this._lightDataUniformName});\\r\\n`;\r\n state.compilationString += `#else\\r\\n`;\r\n state.compilationString += this._declareOutput(direction, state) + ` = ${this._lightDataUniformName};\\r\\n`;\r\n state.compilationString += `#endif\\r\\n`;\r\n\r\n state.compilationString += this._declareOutput(color, state) + ` = ${this._lightColorUniformName}.rgb;\\r\\n`;\r\n state.compilationString += this._declareOutput(intensity, state) + ` = ${this._lightColorUniformName}.a;\\r\\n`;\r\n\r\n if (shadowBias.hasEndpoints || shadowNormalBias.hasEndpoints || shadowDepthScale.hasEndpoints) {\r\n state._emitUniformFromString(this._lightShadowUniformName, \"vec3\");\r\n if (shadowBias.hasEndpoints) {\r\n state.compilationString += this._declareOutput(shadowBias, state) + ` = ${this._lightShadowUniformName}.x;\\r\\n`;\r\n }\r\n if (shadowNormalBias.hasEndpoints) {\r\n state.compilationString += this._declareOutput(shadowNormalBias, state) + ` = ${this._lightShadowUniformName}.y;\\r\\n`;\r\n }\r\n if (shadowDepthScale.hasEndpoints) {\r\n state.compilationString += this._declareOutput(shadowDepthScale, state) + ` = ${this._lightShadowUniformName}.z;\\r\\n`;\r\n }\r\n }\r\n\r\n if (shadowDepthRange.hasEndpoints) {\r\n state._emitUniformFromString(this._lightShadowExtraUniformName, \"vec2\");\r\n state.compilationString += this._declareOutput(shadowDepthRange, state) + ` = ${this._lightShadowUniformName};\\r\\n`;\r\n }\r\n\r\n return this;\r\n }\r\n\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n if (this.light) {\r\n serializationObject.lightId = this.light.id;\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {\r\n super._deserialize(serializationObject, scene, rootUrl);\r\n\r\n if (serializationObject.lightId) {\r\n this.light = scene.getLightById(serializationObject.lightId);\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.LightInformationBlock\", LightInformationBlock);\r\n"]}
|
|
@@ -26,6 +26,7 @@ import { NodeMaterialModes } from "./Enums/nodeMaterialModes";
|
|
|
26
26
|
import type { IParticleSystem } from "../../Particles/IParticleSystem";
|
|
27
27
|
import { ProceduralTexture } from "../Textures/Procedurals/proceduralTexture";
|
|
28
28
|
import type { ImageSourceBlock } from "./Blocks/Dual/imageSourceBlock";
|
|
29
|
+
import type { Material } from "../material";
|
|
29
30
|
/**
|
|
30
31
|
* Interface used to configure the node material editor
|
|
31
32
|
*/
|
|
@@ -318,6 +319,11 @@ export declare class NodeMaterial extends PushMaterial {
|
|
|
318
319
|
* @param onError defines a function to call when the effect creation has failed
|
|
319
320
|
*/
|
|
320
321
|
createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
|
|
322
|
+
/**
|
|
323
|
+
* Use this material as the shadow depth wrapper of a target material
|
|
324
|
+
* @param targetMaterial defines the target material
|
|
325
|
+
*/
|
|
326
|
+
createAsShadowDepthWrapper(targetMaterial: Material): void;
|
|
321
327
|
private _processDefines;
|
|
322
328
|
/**
|
|
323
329
|
* Get if the submesh is ready to be used and all its information available.
|
|
@@ -846,6 +846,17 @@ var NodeMaterial = /** @class */ (function (_super) {
|
|
|
846
846
|
this._createEffectForParticles(particleSystem, BaseParticleSystem.BLENDMODE_ONEONE, onCompiled, onError);
|
|
847
847
|
this._createEffectForParticles(particleSystem, BaseParticleSystem.BLENDMODE_MULTIPLY, onCompiled, onError);
|
|
848
848
|
};
|
|
849
|
+
/**
|
|
850
|
+
* Use this material as the shadow depth wrapper of a target material
|
|
851
|
+
* @param targetMaterial defines the target material
|
|
852
|
+
*/
|
|
853
|
+
NodeMaterial.prototype.createAsShadowDepthWrapper = function (targetMaterial) {
|
|
854
|
+
if (this.mode !== NodeMaterialModes.Material) {
|
|
855
|
+
console.log("Incompatible material mode");
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
targetMaterial.shadowDepthWrapper = new BABYLON.ShadowDepthWrapper(this, this.getScene());
|
|
859
|
+
};
|
|
849
860
|
NodeMaterial.prototype._processDefines = function (mesh, defines, useInstances, subMesh) {
|
|
850
861
|
var _this = this;
|
|
851
862
|
if (useInstances === void 0) { useInstances = false; }
|