@babylonjs/core 5.36.0 → 5.38.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/Cameras/arcRotateCamera.d.ts +2 -2
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Layers/effectLayer.d.ts +9 -5
- package/Layers/effectLayer.js +2 -1
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.d.ts +12 -8
- package/Layers/glowLayer.js +2 -0
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.d.ts +13 -9
- package/Layers/highlightLayer.js +2 -0
- package/Layers/highlightLayer.js.map +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js +2 -3
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/fogBlock.js +4 -4
- package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js +2 -2
- package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +2 -3
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js +3 -4
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.js +2 -2
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +2 -2
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +2 -2
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.d.ts +4 -0
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +35 -19
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js +2 -2
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js +2 -2
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +2 -2
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +2 -2
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js +2 -3
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +2 -2
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/biPlanarBlock.js +4 -2
- package/Materials/Node/Blocks/biPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/gradientBlock.js +7 -6
- package/Materials/Node/Blocks/gradientBlock.js.map +1 -1
- package/Materials/Node/Blocks/normalBlendBlock.js +10 -8
- package/Materials/Node/Blocks/normalBlendBlock.js.map +1 -1
- package/Materials/Node/Blocks/randomNumberBlock.js +6 -5
- package/Materials/Node/Blocks/randomNumberBlock.js.map +1 -1
- package/Materials/Node/Blocks/reflectBlock.js +10 -8
- package/Materials/Node/Blocks/reflectBlock.js.map +1 -1
- package/Materials/Node/Blocks/refractBlock.js +10 -8
- package/Materials/Node/Blocks/refractBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.d.ts +27 -1
- package/Materials/Node/Blocks/triPlanarBlock.js +67 -10
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes.d.ts +3 -1
- package/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes.js +2 -0
- package/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes.js.map +1 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.d.ts +5 -0
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js +13 -0
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
- package/Materials/Node/nodeMaterialConnectionPointCustomObject.d.ts +1 -3
- package/Materials/Node/nodeMaterialConnectionPointCustomObject.js +2 -7
- package/Materials/Node/nodeMaterialConnectionPointCustomObject.js.map +1 -1
- package/Materials/Textures/videoTexture.d.ts +5 -0
- package/Materials/Textures/videoTexture.js +27 -23
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/materialHelper.js +3 -0
- package/Materials/materialHelper.js.map +1 -1
- package/Misc/virtualJoystick.d.ts +1 -0
- package/Misc/virtualJoystick.js +6 -0
- package/Misc/virtualJoystick.js.map +1 -1
- package/Physics/physicsEngineComponent.js +1 -1
- package/Physics/physicsEngineComponent.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"biPlanarBlock.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/biPlanarBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,cAAc;IAC7C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"biPlanarBlock.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/biPlanarBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;GAEG;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AQ,CAAC,sBAAsB;mBACnD,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,sBAAsB;;;oBAG5C,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;uBAC/B,CAAC,MAAM,CAAC;;;oBAGX,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;uBAC/B,CAAC,MAAM,CAAC;;;oBAGX,EAAE,iBAAiB,EAAE,MAAM,EAAE;;;mBAG9B,CAAC,mBAAmB,WAAW,aAAa,IAAI,CAAC,QAAQ,CAAC,sBAAsB,IAAI,EAAE,UAAU,IAAI,CAAC,QAAQ,CAAC,sBAAsB,IAAI,EAAE;2CAClH,IAAI,IAAI,EAAE,OAAO,IAAI,IAAI,EAAE;2CAC3B,IAAI,IAAI,EAAE,OAAO,IAAI,IAAI,EAAE;mBACnD,CAAC,mBAAmB,YAAY,aAAa,IAAI,CAAC,QAAQ,CAAC,sBAAsB,IAAI,EAAE,UAAU,IAAI,CAAC,QAAQ,CAAC,sBAAsB,IAAI,EAAE;2CACnH,IAAI,IAAI,EAAE,OAAO,IAAI,IAAI,EAAE;2CAC3B,IAAI,IAAI,EAAE,OAAO,IAAI,IAAI,EAAE;;;mBAGnD,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE;;cAEtC,CAAC,cAAc,CAAC;;cAEhB,CAAC,WAAW,CAAC,UAAU,SAAS;;mBAE3B,IAAI,CAAC,gBAAgB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;SAC9E,CAAC;IACN,CAAC;CACJ;AAED,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import type { NodeMaterialBuildState } from \"../nodeMaterialBuildState\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { TriPlanarBlock } from \"./triPlanarBlock\";\r\n\r\n/**\r\n * Block used to read a texture with triplanar mapping (see https://iquilezles.org/articles/biplanar/)\r\n */\r\nexport class BiPlanarBlock extends TriPlanarBlock {\r\n /**\r\n * Create a new BiPlanarBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, true);\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 \"BiPlanarBlock\";\r\n }\r\n\r\n protected _generateTextureLookup(state: NodeMaterialBuildState): void {\r\n const samplerName = this.samplerName;\r\n const samplerYName = this.samplerYName ?? this.samplerName;\r\n\r\n const sharpness = this.sharpness.isConnected ? this.sharpness.associatedVariableName : \"1.0\";\r\n\r\n const dpdx = state._getFreeVariableName(\"dpdx\");\r\n const dpdy = state._getFreeVariableName(\"dpdy\");\r\n const n = state._getFreeVariableName(\"n\");\r\n const ma = state._getFreeVariableName(\"ma\");\r\n const mi = state._getFreeVariableName(\"mi\");\r\n const me = state._getFreeVariableName(\"me\");\r\n const x = state._getFreeVariableName(\"x\");\r\n const y = state._getFreeVariableName(\"y\");\r\n const w = state._getFreeVariableName(\"y\");\r\n\r\n state.compilationString += `\r\n // grab coord derivatives for texturing\r\n vec3 ${dpdx} = dFdx(${this.position.associatedVariableName}.xyz);\r\n vec3 ${dpdy} = dFdy(${this.position.associatedVariableName}.xyz);\r\n vec3 ${n} = abs(${this.normal.associatedVariableName}.xyz);\r\n \r\n // determine major axis (in x; yz are following axis)\r\n ivec3 ${ma} = (${n}.x>${n}.y && ${n}.x>${n}.z) ? ivec3(0,1,2) :\r\n (${n}.y>${n}.z) ? ivec3(1,2,0) :\r\n ivec3(2,0,1) ;\r\n // determine minor axis (in x; yz are following axis)\r\n ivec3 ${mi} = (${n}.x<${n}.y && ${n}.x<${n}.z) ? ivec3(0,1,2) :\r\n (${n}.y<${n}.z) ? ivec3(1,2,0) :\r\n ivec3(2,0,1) ;\r\n // determine median axis (in x; yz are following axis)\r\n ivec3 ${me} = ivec3(3) - ${mi} - ${ma};\r\n \r\n // project+fetch\r\n vec4 ${x} = textureGrad( ${samplerName}, vec2( ${this.position.associatedVariableName}[${ma}.y], ${this.position.associatedVariableName}[${ma}.z]), \r\n vec2(${dpdx}[${ma}.y],${dpdx}[${ma}.z]), \r\n vec2(${dpdy}[${ma}.y],${dpdy}[${ma}.z]) );\r\n vec4 ${y} = textureGrad( ${samplerYName}, vec2( ${this.position.associatedVariableName}[${me}.y], ${this.position.associatedVariableName}[${me}.z]), \r\n vec2(${dpdx}[${me}.y],${dpdx}[${me}.z]),\r\n vec2(${dpdy}[${me}.y],${dpdy}[${me}.z]) );\r\n \r\n // blend factors\r\n vec2 ${w} = vec2(${n}[${ma}.x],${n}[${me}.x]);\r\n // make local support\r\n ${w} = clamp( (${w}-0.5773)/(1.0-0.5773), 0.0, 1.0 );\r\n // shape transition\r\n ${w} = pow( ${w}, vec2(${sharpness}/8.0) );\r\n // blend and return\r\n vec4 ${this._tempTextureRead} = (${x}*${w}.x + ${y}*${w}.y) / (${w}.x + ${w}.y);\r\n `;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BiPlanarBlock\", BiPlanarBlock);\r\n"]}
|
|
@@ -58,13 +58,14 @@ export class GradientBlock extends NodeMaterialBlock {
|
|
|
58
58
|
this.colorSteps = [new GradientBlockColorStep(0, Color3.Black()), new GradientBlockColorStep(1.0, Color3.White())];
|
|
59
59
|
/** Gets an observable raised when the value is changed */
|
|
60
60
|
this.onValueChangedObservable = new Observable();
|
|
61
|
-
this.registerInput("gradient", NodeMaterialBlockConnectionPointTypes.
|
|
61
|
+
this.registerInput("gradient", NodeMaterialBlockConnectionPointTypes.AutoDetect);
|
|
62
62
|
this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Color3);
|
|
63
|
-
this._inputs[0].
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
this._inputs[0].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Float |
|
|
64
|
+
NodeMaterialBlockConnectionPointTypes.Vector2 |
|
|
65
|
+
NodeMaterialBlockConnectionPointTypes.Vector3 |
|
|
66
|
+
NodeMaterialBlockConnectionPointTypes.Vector4 |
|
|
67
|
+
NodeMaterialBlockConnectionPointTypes.Color3 |
|
|
68
|
+
NodeMaterialBlockConnectionPointTypes.Color4);
|
|
68
69
|
}
|
|
69
70
|
/** calls observable when the value is changed*/
|
|
70
71
|
colorStepsUpdated() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gradientBlock.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/gradientBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAgC/B;;;;OAIG;IACH,YAAmB,IAAY,EAAE,KAAa;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAtCD;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,IAAI,CAAC,GAAW;QACvB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IACrB,CAAC;IAID;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK,CAAC,GAAW;QACxB,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;IACtB,CA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\";\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 { Color3 } from \"../../../Maths/math.color\";\r\nimport type { Scene } from \"../../../scene\";\r\nimport { Observable } from \"../../../Misc/observable\";\r\n\r\n/**\r\n * Class used to store a color step for the GradientBlock\r\n */\r\nexport class GradientBlockColorStep {\r\n private _step: number;\r\n /**\r\n * Gets value indicating which step this color is associated with (between 0 and 1)\r\n */\r\n public get step(): number {\r\n return this._step;\r\n }\r\n\r\n /**\r\n * Sets a value indicating which step this color is associated with (between 0 and 1)\r\n */\r\n public set step(val: number) {\r\n this._step = val;\r\n }\r\n\r\n private _color: Color3;\r\n\r\n /**\r\n * Gets the color associated with this step\r\n */\r\n public get color(): Color3 {\r\n return this._color;\r\n }\r\n\r\n /**\r\n * Sets the color associated with this step\r\n */\r\n public set color(val: Color3) {\r\n this._color = val;\r\n }\r\n\r\n /**\r\n * Creates a new GradientBlockColorStep\r\n * @param step defines a value indicating which step this color is associated with (between 0 and 1)\r\n * @param color defines the color associated with this step\r\n */\r\n public constructor(step: number, color: Color3) {\r\n this.step = step;\r\n this.color = color;\r\n }\r\n}\r\n\r\n/**\r\n * Block used to return a color from a gradient based on an input value between 0 and 1\r\n */\r\nexport class GradientBlock extends NodeMaterialBlock {\r\n /**\r\n * Gets or sets the list of color steps\r\n */\r\n public colorSteps: GradientBlockColorStep[] = [new GradientBlockColorStep(0, Color3.Black()), new GradientBlockColorStep(1.0, Color3.White())];\r\n\r\n /** Gets an observable raised when the value is changed */\r\n public onValueChangedObservable = new Observable<GradientBlock>();\r\n\r\n /** calls observable when the value is changed*/\r\n public colorStepsUpdated() {\r\n this.onValueChangedObservable.notifyObservers(this);\r\n }\r\n /**\r\n * Creates a new GradientBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Neutral);\r\n\r\n this.registerInput(\"gradient\", NodeMaterialBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Color3);\r\n\r\n this._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2);\r\n this._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3);\r\n this._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4);\r\n this._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3);\r\n this._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4);\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 \"GradientBlock\";\r\n }\r\n\r\n /**\r\n * Gets the gradient input component\r\n */\r\n public get gradient(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n private _writeColorConstant(index: number) {\r\n const step = this.colorSteps[index];\r\n return `vec3(${step.color.r}, ${step.color.g}, ${step.color.b})`;\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const output = this._outputs[0];\r\n\r\n if (!this.colorSteps.length || !this.gradient.connectedPoint) {\r\n state.compilationString += this._declareOutput(output, state) + ` = vec3(0., 0., 0.);\\r\\n`;\r\n return;\r\n }\r\n\r\n const tempColor = state._getFreeVariableName(\"gradientTempColor\");\r\n const tempPosition = state._getFreeVariableName(\"gradientTempPosition\");\r\n\r\n state.compilationString += `vec3 ${tempColor} = ${this._writeColorConstant(0)};\\r\\n`;\r\n state.compilationString += `float ${tempPosition};\\r\\n`;\r\n\r\n let gradientSource = this.gradient.associatedVariableName;\r\n\r\n if (this.gradient.connectedPoint!.type !== NodeMaterialBlockConnectionPointTypes.Float) {\r\n gradientSource += \".x\";\r\n }\r\n\r\n for (let index = 1; index < this.colorSteps.length; index++) {\r\n const step = this.colorSteps[index];\r\n const previousStep = this.colorSteps[index - 1];\r\n state.compilationString += `${tempPosition} = clamp((${gradientSource} - ${state._emitFloat(previousStep.step)}) / (${state._emitFloat(\r\n step.step\r\n )} - ${state._emitFloat(previousStep.step)}), 0.0, 1.0) * step(${state._emitFloat(index)}, ${state._emitFloat(this.colorSteps.length - 1)});\\r\\n`;\r\n state.compilationString += `${tempColor} = mix(${tempColor}, ${this._writeColorConstant(index)}, ${tempPosition});\\r\\n`;\r\n }\r\n state.compilationString += this._declareOutput(output, state) + ` = ${tempColor};\\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 serializationObject.colorSteps = [];\r\n\r\n for (const step of this.colorSteps) {\r\n serializationObject.colorSteps.push({\r\n step: step.step,\r\n color: {\r\n r: step.color.r,\r\n g: step.color.g,\r\n b: step.color.b,\r\n },\r\n });\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 this.colorSteps.length = 0;\r\n\r\n for (const step of serializationObject.colorSteps) {\r\n this.colorSteps.push(new GradientBlockColorStep(step.step, new Color3(step.color.r, step.color.g, step.color.b)));\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode();\r\n\r\n codeString += `${this._codeVariableName}.colorSteps = [];\\r\\n`;\r\n\r\n for (const colorStep of this.colorSteps) {\r\n codeString += `${this._codeVariableName}.colorSteps.push(new BABYLON.GradientBlockColorStep(${colorStep.step}, new BABYLON.Color3(${colorStep.color.r}, ${colorStep.color.g}, ${colorStep.color.b})));\\r\\n`;\r\n }\r\n\r\n return codeString;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GradientBlock\", GradientBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"gradientBlock.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/gradientBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAgC/B;;;;OAIG;IACH,YAAmB,IAAY,EAAE,KAAa;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAtCD;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,IAAI,CAAC,GAAW;QACvB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IACrB,CAAC;IAID;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK,CAAC,GAAW;QACxB,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;IACtB,CAAC;CAWJ;AAED;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAahD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,O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CAAC,UAAU,EAAE;YAC/C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACrH;IACL,CAAC;IAES,mBAAmB;QACzB,IAAI,UAAU,GAAG,KAAK,CAAC,mBAAmB,EAAE,CAAC;QAE7C,UAAU,IAAI,GAAG,IAAI,CAAC,iBAAiB,uBAAuB,CAAC;QAE/D,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE;YACrC,UAAU,IAAI,GAAG,IAAI,CAAC,iBAAiB,uDAAuD,SAAS,CAAC,IAAI,wBAAwB,SAAS,CAAC,KAAK,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC;SAC/M;QAED,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AAED,aAAa,CAAC,uBAAuB,EAAE,aAAa,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 { Color3 } from \"../../../Maths/math.color\";\r\nimport type { Scene } from \"../../../scene\";\r\nimport { Observable } from \"../../../Misc/observable\";\r\n\r\n/**\r\n * Class used to store a color step for the GradientBlock\r\n */\r\nexport class GradientBlockColorStep {\r\n private _step: number;\r\n /**\r\n * Gets value indicating which step this color is associated with (between 0 and 1)\r\n */\r\n public get step(): number {\r\n return this._step;\r\n }\r\n\r\n /**\r\n * Sets a value indicating which step this color is associated with (between 0 and 1)\r\n */\r\n public set step(val: number) {\r\n this._step = val;\r\n }\r\n\r\n private _color: Color3;\r\n\r\n /**\r\n * Gets the color associated with this step\r\n */\r\n public get color(): Color3 {\r\n return this._color;\r\n }\r\n\r\n /**\r\n * Sets the color associated with this step\r\n */\r\n public set color(val: Color3) {\r\n this._color = val;\r\n }\r\n\r\n /**\r\n * Creates a new GradientBlockColorStep\r\n * @param step defines a value indicating which step this color is associated with (between 0 and 1)\r\n * @param color defines the color associated with this step\r\n */\r\n public constructor(step: number, color: Color3) {\r\n this.step = step;\r\n this.color = color;\r\n }\r\n}\r\n\r\n/**\r\n * Block used to return a color from a gradient based on an input value between 0 and 1\r\n */\r\nexport class GradientBlock extends NodeMaterialBlock {\r\n /**\r\n * Gets or sets the list of color steps\r\n */\r\n public colorSteps: GradientBlockColorStep[] = [new GradientBlockColorStep(0, Color3.Black()), new GradientBlockColorStep(1.0, Color3.White())];\r\n\r\n /** Gets an observable raised when the value is changed */\r\n public onValueChangedObservable = new Observable<GradientBlock>();\r\n\r\n /** calls observable when the value is changed*/\r\n public colorStepsUpdated() {\r\n this.onValueChangedObservable.notifyObservers(this);\r\n }\r\n /**\r\n * Creates a new GradientBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Neutral);\r\n\r\n this.registerInput(\"gradient\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Color3);\r\n\r\n this._inputs[0].addExcludedConnectionPointFromAllowedTypes(\r\n NodeMaterialBlockConnectionPointTypes.Float |\r\n NodeMaterialBlockConnectionPointTypes.Vector2 |\r\n NodeMaterialBlockConnectionPointTypes.Vector3 |\r\n NodeMaterialBlockConnectionPointTypes.Vector4 |\r\n NodeMaterialBlockConnectionPointTypes.Color3 |\r\n NodeMaterialBlockConnectionPointTypes.Color4\r\n );\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 \"GradientBlock\";\r\n }\r\n\r\n /**\r\n * Gets the gradient input component\r\n */\r\n public get gradient(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n private _writeColorConstant(index: number) {\r\n const step = this.colorSteps[index];\r\n return `vec3(${step.color.r}, ${step.color.g}, ${step.color.b})`;\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const output = this._outputs[0];\r\n\r\n if (!this.colorSteps.length || !this.gradient.connectedPoint) {\r\n state.compilationString += this._declareOutput(output, state) + ` = vec3(0., 0., 0.);\\r\\n`;\r\n return;\r\n }\r\n\r\n const tempColor = state._getFreeVariableName(\"gradientTempColor\");\r\n const tempPosition = state._getFreeVariableName(\"gradientTempPosition\");\r\n\r\n state.compilationString += `vec3 ${tempColor} = ${this._writeColorConstant(0)};\\r\\n`;\r\n state.compilationString += `float ${tempPosition};\\r\\n`;\r\n\r\n let gradientSource = this.gradient.associatedVariableName;\r\n\r\n if (this.gradient.connectedPoint!.type !== NodeMaterialBlockConnectionPointTypes.Float) {\r\n gradientSource += \".x\";\r\n }\r\n\r\n for (let index = 1; index < this.colorSteps.length; index++) {\r\n const step = this.colorSteps[index];\r\n const previousStep = this.colorSteps[index - 1];\r\n state.compilationString += `${tempPosition} = clamp((${gradientSource} - ${state._emitFloat(previousStep.step)}) / (${state._emitFloat(\r\n step.step\r\n )} - ${state._emitFloat(previousStep.step)}), 0.0, 1.0) * step(${state._emitFloat(index)}, ${state._emitFloat(this.colorSteps.length - 1)});\\r\\n`;\r\n state.compilationString += `${tempColor} = mix(${tempColor}, ${this._writeColorConstant(index)}, ${tempPosition});\\r\\n`;\r\n }\r\n state.compilationString += this._declareOutput(output, state) + ` = ${tempColor};\\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 serializationObject.colorSteps = [];\r\n\r\n for (const step of this.colorSteps) {\r\n serializationObject.colorSteps.push({\r\n step: step.step,\r\n color: {\r\n r: step.color.r,\r\n g: step.color.g,\r\n b: step.color.b,\r\n },\r\n });\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 this.colorSteps.length = 0;\r\n\r\n for (const step of serializationObject.colorSteps) {\r\n this.colorSteps.push(new GradientBlockColorStep(step.step, new Color3(step.color.r, step.color.g, step.color.b)));\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode();\r\n\r\n codeString += `${this._codeVariableName}.colorSteps = [];\\r\\n`;\r\n\r\n for (const colorStep of this.colorSteps) {\r\n codeString += `${this._codeVariableName}.colorSteps.push(new BABYLON.GradientBlockColorStep(${colorStep.step}, new BABYLON.Color3(${colorStep.color.r}, ${colorStep.color.g}, ${colorStep.color.b})));\\r\\n`;\r\n }\r\n\r\n return codeString;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GradientBlock\", GradientBlock);\r\n"]}
|
|
@@ -12,15 +12,17 @@ export class NormalBlendBlock extends NodeMaterialBlock {
|
|
|
12
12
|
*/
|
|
13
13
|
constructor(name) {
|
|
14
14
|
super(name, NodeMaterialBlockTargets.Neutral);
|
|
15
|
-
this.registerInput("normalMap0", NodeMaterialBlockConnectionPointTypes.
|
|
16
|
-
this.registerInput("normalMap1", NodeMaterialBlockConnectionPointTypes.
|
|
15
|
+
this.registerInput("normalMap0", NodeMaterialBlockConnectionPointTypes.AutoDetect);
|
|
16
|
+
this.registerInput("normalMap1", NodeMaterialBlockConnectionPointTypes.AutoDetect);
|
|
17
17
|
this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3);
|
|
18
|
-
this._inputs[0].
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this._inputs[1].
|
|
23
|
-
|
|
18
|
+
this._inputs[0].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Color3 |
|
|
19
|
+
NodeMaterialBlockConnectionPointTypes.Color4 |
|
|
20
|
+
NodeMaterialBlockConnectionPointTypes.Vector3 |
|
|
21
|
+
NodeMaterialBlockConnectionPointTypes.Vector4);
|
|
22
|
+
this._inputs[1].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Color3 |
|
|
23
|
+
NodeMaterialBlockConnectionPointTypes.Color4 |
|
|
24
|
+
NodeMaterialBlockConnectionPointTypes.Vector3 |
|
|
25
|
+
NodeMaterialBlockConnectionPointTypes.Vector4);
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Gets the current class name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalBlendBlock.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/normalBlendBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IACnD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC;QAE9C,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,
|
|
1
|
+
{"version":3,"file":"normalBlendBlock.js","sourceRoot":"","sources":["../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AC;QAC3R,KAAK,CAAC,iBAAiB,IAAI,GAAG,MAAM,CAAC,sBAAsB,QAAQ,MAAM,CAAC,sBAAsB,QAAQ,MAAM,CAAC,sBAAsB,SAAS,CAAC;QAE/I,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,0BAA0B,EAAE,gBAAgB,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\n/**\r\n * Block used to blend normals\r\n */\r\nexport class NormalBlendBlock extends NodeMaterialBlock {\r\n /**\r\n * Creates a new NormalBlendBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Neutral);\r\n\r\n this.registerInput(\"normalMap0\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"normalMap1\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Vector3);\r\n\r\n this._inputs[0].addExcludedConnectionPointFromAllowedTypes(\r\n NodeMaterialBlockConnectionPointTypes.Color3 |\r\n NodeMaterialBlockConnectionPointTypes.Color4 |\r\n NodeMaterialBlockConnectionPointTypes.Vector3 |\r\n NodeMaterialBlockConnectionPointTypes.Vector4\r\n );\r\n\r\n this._inputs[1].addExcludedConnectionPointFromAllowedTypes(\r\n NodeMaterialBlockConnectionPointTypes.Color3 |\r\n NodeMaterialBlockConnectionPointTypes.Color4 |\r\n NodeMaterialBlockConnectionPointTypes.Vector3 |\r\n NodeMaterialBlockConnectionPointTypes.Vector4\r\n );\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 \"NormalBlendBlock\";\r\n }\r\n\r\n /**\r\n * Gets the first input component\r\n */\r\n public get normalMap0(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the second input component\r\n */\r\n public get normalMap1(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const output = this._outputs[0];\r\n const input0 = this._inputs[0];\r\n const input1 = this._inputs[1];\r\n const stepR = state._getFreeVariableName(\"stepR\");\r\n const stepG = state._getFreeVariableName(\"stepG\");\r\n\r\n state.compilationString += `float ${stepR} = step(0.5, ${input0.associatedVariableName}.r);\\r\\n`;\r\n state.compilationString += `float ${stepG} = step(0.5, ${input0.associatedVariableName}.g);\\r\\n`;\r\n state.compilationString += this._declareOutput(output, state) + `;\\r\\n`;\r\n state.compilationString += `${output.associatedVariableName}.r = (1.0 - ${stepR}) * ${input0.associatedVariableName}.r * ${input1.associatedVariableName}.r * 2.0 + ${stepR} * (1.0 - (1.0 - ${input0.associatedVariableName}.r) * (1.0 - ${input1.associatedVariableName}.r) * 2.0);\\r\\n`;\r\n state.compilationString += `${output.associatedVariableName}.g = (1.0 - ${stepG}) * ${input0.associatedVariableName}.g * ${input1.associatedVariableName}.g * 2.0 + ${stepG} * (1.0 - (1.0 - ${input0.associatedVariableName}.g) * (1.0 - ${input1.associatedVariableName}.g) * 2.0);\\r\\n`;\r\n state.compilationString += `${output.associatedVariableName}.b = ${input0.associatedVariableName}.b * ${input1.associatedVariableName}.b;\\r\\n`;\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.NormalBlendBlock\", NormalBlendBlock);\r\n"]}
|
|
@@ -13,12 +13,13 @@ export class RandomNumberBlock extends NodeMaterialBlock {
|
|
|
13
13
|
*/
|
|
14
14
|
constructor(name) {
|
|
15
15
|
super(name, NodeMaterialBlockTargets.Neutral);
|
|
16
|
-
this.registerInput("seed", NodeMaterialBlockConnectionPointTypes.
|
|
16
|
+
this.registerInput("seed", NodeMaterialBlockConnectionPointTypes.AutoDetect);
|
|
17
17
|
this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float);
|
|
18
|
-
this._inputs[0].
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
this._inputs[0].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Vector2 |
|
|
19
|
+
NodeMaterialBlockConnectionPointTypes.Vector3 |
|
|
20
|
+
NodeMaterialBlockConnectionPointTypes.Vector4 |
|
|
21
|
+
NodeMaterialBlockConnectionPointTypes.Color3 |
|
|
22
|
+
NodeMaterialBlockConnectionPointTypes.Color4);
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Gets the current class name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randomNumberBlock.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/randomNumberBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,iDAAiD,CAAC;AAEzD;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IACpD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC;QAE9C,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,qCAAqC,CAAC,
|
|
1
|
+
{"version":3,"file":"randomNumberBlock.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/randomNumberBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,iDAAiD,CAAC;AAEzD;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IACpD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC;QAE9C,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC7E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,KAAK,CAAC,CAAC;QAE3E,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,0CAA0C,CACtD,qCAAqC,CAAC,OAAO;YACzC,qCAAqC,CAAC,OAAO;YAC7C,qCAAqC,CAAC,OAAO;YAC7C,qCAAqC,CAAC,MAAM;YAC5C,qCAAqC,CAAC,MAAM,CACnD,CAAC;IACN,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAES,WAAW,CAAC,KAA6B;QAC/C,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEzB,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEhC,MAAM,QAAQ,GAAG,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QAClC,KAAK,CAAC,wBAAwB,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QAE5D,KAAK,CAAC,iBAAiB,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,cAAc,IAAI,CAAC,IAAI,CAAC,sBAAsB,WAAW,CAAC;QAE1H,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,2BAA2B,EAAE,iBAAiB,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\n\r\nimport \"../../../Shaders/ShadersInclude/helperFunctions\";\r\n\r\n/**\r\n * Block used to get a random number\r\n */\r\nexport class RandomNumberBlock extends NodeMaterialBlock {\r\n /**\r\n * Creates a new RandomNumberBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Neutral);\r\n\r\n this.registerInput(\"seed\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Float);\r\n\r\n this._inputs[0].addExcludedConnectionPointFromAllowedTypes(\r\n NodeMaterialBlockConnectionPointTypes.Vector2 |\r\n NodeMaterialBlockConnectionPointTypes.Vector3 |\r\n NodeMaterialBlockConnectionPointTypes.Vector4 |\r\n NodeMaterialBlockConnectionPointTypes.Color3 |\r\n NodeMaterialBlockConnectionPointTypes.Color4\r\n );\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 \"RandomNumberBlock\";\r\n }\r\n\r\n /**\r\n * Gets the seed input component\r\n */\r\n public get seed(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const output = this._outputs[0];\r\n\r\n const comments = `//${this.name}`;\r\n state._emitFunctionFromInclude(\"helperFunctions\", comments);\r\n\r\n state.compilationString += this._declareOutput(output, state) + ` = getRand(${this.seed.associatedVariableName}.xy);\\r\\n`;\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.RandomNumberBlock\", RandomNumberBlock);\r\n"]}
|
|
@@ -12,15 +12,17 @@ export class ReflectBlock extends NodeMaterialBlock {
|
|
|
12
12
|
*/
|
|
13
13
|
constructor(name) {
|
|
14
14
|
super(name, NodeMaterialBlockTargets.Neutral);
|
|
15
|
-
this.registerInput("incident", NodeMaterialBlockConnectionPointTypes.
|
|
16
|
-
this.registerInput("normal", NodeMaterialBlockConnectionPointTypes.
|
|
15
|
+
this.registerInput("incident", NodeMaterialBlockConnectionPointTypes.AutoDetect);
|
|
16
|
+
this.registerInput("normal", NodeMaterialBlockConnectionPointTypes.AutoDetect);
|
|
17
17
|
this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3);
|
|
18
|
-
this._inputs[0].
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this._inputs[1].
|
|
23
|
-
|
|
18
|
+
this._inputs[0].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Vector3 |
|
|
19
|
+
NodeMaterialBlockConnectionPointTypes.Vector4 |
|
|
20
|
+
NodeMaterialBlockConnectionPointTypes.Color3 |
|
|
21
|
+
NodeMaterialBlockConnectionPointTypes.Color4);
|
|
22
|
+
this._inputs[1].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Vector3 |
|
|
23
|
+
NodeMaterialBlockConnectionPointTypes.Vector4 |
|
|
24
|
+
NodeMaterialBlockConnectionPointTypes.Color3 |
|
|
25
|
+
NodeMaterialBlockConnectionPointTypes.Color4);
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Gets the current class name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflectBlock.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/reflectBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,iBAAiB;IAC/C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC;QAE9C,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,
|
|
1
|
+
{"version":3,"file":"reflectBlock.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/reflectBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD;;GAEG;AACH,MAAM,OAAO,YAAa,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AI,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,cAAc,IAAI,CAAC,QAAQ,CAAC,sBAAsB,SAAS,IAAI,CAAC,MAAM,CAAC,sBAAsB,YAAY,CAAC;QAE1K,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,sBAAsB,EAAE,YAAY,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\n/**\r\n * Block used to get the reflected vector from a direction and a normal\r\n */\r\nexport class ReflectBlock extends NodeMaterialBlock {\r\n /**\r\n * Creates a new ReflectBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Neutral);\r\n\r\n this.registerInput(\"incident\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"normal\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Vector3);\r\n\r\n this._inputs[0].addExcludedConnectionPointFromAllowedTypes(\r\n NodeMaterialBlockConnectionPointTypes.Vector3 |\r\n NodeMaterialBlockConnectionPointTypes.Vector4 |\r\n NodeMaterialBlockConnectionPointTypes.Color3 |\r\n NodeMaterialBlockConnectionPointTypes.Color4\r\n );\r\n this._inputs[1].addExcludedConnectionPointFromAllowedTypes(\r\n NodeMaterialBlockConnectionPointTypes.Vector3 |\r\n NodeMaterialBlockConnectionPointTypes.Vector4 |\r\n NodeMaterialBlockConnectionPointTypes.Color3 |\r\n NodeMaterialBlockConnectionPointTypes.Color4\r\n );\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 \"ReflectBlock\";\r\n }\r\n\r\n /**\r\n * Gets the incident component\r\n */\r\n public get incident(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the normal component\r\n */\r\n public get normal(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const output = this._outputs[0];\r\n\r\n state.compilationString += this._declareOutput(output, state) + ` = reflect(${this.incident.associatedVariableName}.xyz, ${this.normal.associatedVariableName}.xyz);\\r\\n`;\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ReflectBlock\", ReflectBlock);\r\n"]}
|
|
@@ -12,16 +12,18 @@ export class RefractBlock extends NodeMaterialBlock {
|
|
|
12
12
|
*/
|
|
13
13
|
constructor(name) {
|
|
14
14
|
super(name, NodeMaterialBlockTargets.Neutral);
|
|
15
|
-
this.registerInput("incident", NodeMaterialBlockConnectionPointTypes.
|
|
16
|
-
this.registerInput("normal", NodeMaterialBlockConnectionPointTypes.
|
|
15
|
+
this.registerInput("incident", NodeMaterialBlockConnectionPointTypes.AutoDetect);
|
|
16
|
+
this.registerInput("normal", NodeMaterialBlockConnectionPointTypes.AutoDetect);
|
|
17
17
|
this.registerInput("ior", NodeMaterialBlockConnectionPointTypes.Float);
|
|
18
18
|
this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3);
|
|
19
|
-
this._inputs[0].
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this._inputs[1].
|
|
24
|
-
|
|
19
|
+
this._inputs[0].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Vector3 |
|
|
20
|
+
NodeMaterialBlockConnectionPointTypes.Vector4 |
|
|
21
|
+
NodeMaterialBlockConnectionPointTypes.Color3 |
|
|
22
|
+
NodeMaterialBlockConnectionPointTypes.Color4);
|
|
23
|
+
this._inputs[1].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Vector3 |
|
|
24
|
+
NodeMaterialBlockConnectionPointTypes.Vector4 |
|
|
25
|
+
NodeMaterialBlockConnectionPointTypes.Color3 |
|
|
26
|
+
NodeMaterialBlockConnectionPointTypes.Color4);
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
29
|
* Gets the current class name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refractBlock.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/refractBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,iBAAiB;IAC/C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC;QAE9C,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,
|
|
1
|
+
{"version":3,"file":"refractBlock.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/refractBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE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AAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAES,WAAW,CAAC,KAA6B;QAC/C,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEzB,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEhC,KAAK,CAAC,iBAAiB;YACnB,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC;gBAClC,cAAc,IAAI,CAAC,QAAQ,CAAC,sBAAsB,SAAS,IAAI,CAAC,MAAM,CAAC,sBAAsB,SAAS,IAAI,CAAC,GAAG,CAAC,sBAAsB,QAAQ,CAAC;QAElJ,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,sBAAsB,EAAE,YAAY,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\n/**\r\n * Block used to get the refracted vector from a direction and a normal\r\n */\r\nexport class RefractBlock extends NodeMaterialBlock {\r\n /**\r\n * Creates a new RefractBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Neutral);\r\n\r\n this.registerInput(\"incident\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"normal\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"ior\", NodeMaterialBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Vector3);\r\n\r\n this._inputs[0].addExcludedConnectionPointFromAllowedTypes(\r\n NodeMaterialBlockConnectionPointTypes.Vector3 |\r\n NodeMaterialBlockConnectionPointTypes.Vector4 |\r\n NodeMaterialBlockConnectionPointTypes.Color3 |\r\n NodeMaterialBlockConnectionPointTypes.Color4\r\n );\r\n this._inputs[1].addExcludedConnectionPointFromAllowedTypes(\r\n NodeMaterialBlockConnectionPointTypes.Vector3 |\r\n NodeMaterialBlockConnectionPointTypes.Vector4 |\r\n NodeMaterialBlockConnectionPointTypes.Color3 |\r\n NodeMaterialBlockConnectionPointTypes.Color4\r\n );\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 \"RefractBlock\";\r\n }\r\n\r\n /**\r\n * Gets the incident component\r\n */\r\n public get incident(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the normal component\r\n */\r\n public get normal(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the index of refraction component\r\n */\r\n public get ior(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const output = this._outputs[0];\r\n\r\n state.compilationString +=\r\n this._declareOutput(output, state) +\r\n ` = refract(${this.incident.associatedVariableName}.xyz, ${this.normal.associatedVariableName}.xyz, ${this.ior.associatedVariableName});\\r\\n`;\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.RefractBlock\", RefractBlock);\r\n"]}
|
|
@@ -9,6 +9,7 @@ import type { Nullable } from "../../../types";
|
|
|
9
9
|
import { Texture } from "../../Textures/texture";
|
|
10
10
|
import type { Scene } from "../../../scene";
|
|
11
11
|
import "../../../Shaders/ShadersInclude/helperFunctions";
|
|
12
|
+
import { ImageSourceBlock } from "./Dual/imageSourceBlock";
|
|
12
13
|
/**
|
|
13
14
|
* Block used to read a texture with triplanar mapping (see "boxmap" in https://iquilezles.org/articles/biplanar/)
|
|
14
15
|
*/
|
|
@@ -25,10 +26,27 @@ export declare class TriPlanarBlock extends NodeMaterialBlock {
|
|
|
25
26
|
*/
|
|
26
27
|
get texture(): Nullable<Texture>;
|
|
27
28
|
set texture(texture: Nullable<Texture>);
|
|
29
|
+
/**
|
|
30
|
+
* Gets the textureY associated with the node
|
|
31
|
+
*/
|
|
32
|
+
get textureY(): Nullable<Texture>;
|
|
33
|
+
/**
|
|
34
|
+
* Gets the textureZ associated with the node
|
|
35
|
+
*/
|
|
36
|
+
get textureZ(): Nullable<Texture>;
|
|
37
|
+
protected _getImageSourceBlock(connectionPoint: Nullable<NodeMaterialConnectionPoint>): Nullable<ImageSourceBlock>;
|
|
28
38
|
/**
|
|
29
39
|
* Gets the sampler name associated with this texture
|
|
30
40
|
*/
|
|
31
41
|
get samplerName(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the samplerY name associated with this texture
|
|
44
|
+
*/
|
|
45
|
+
get samplerYName(): Nullable<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Gets the samplerZ name associated with this texture
|
|
48
|
+
*/
|
|
49
|
+
get samplerZName(): Nullable<string>;
|
|
32
50
|
/**
|
|
33
51
|
* Gets a boolean indicating that this block is linked to an ImageSourceBlock
|
|
34
52
|
*/
|
|
@@ -53,7 +71,7 @@ export declare class TriPlanarBlock extends NodeMaterialBlock {
|
|
|
53
71
|
* Create a new TriPlanarBlock
|
|
54
72
|
* @param name defines the block name
|
|
55
73
|
*/
|
|
56
|
-
constructor(name: string);
|
|
74
|
+
constructor(name: string, hideSourceZ?: boolean);
|
|
57
75
|
/**
|
|
58
76
|
* Gets the current class name
|
|
59
77
|
* @returns the class name
|
|
@@ -75,6 +93,14 @@ export declare class TriPlanarBlock extends NodeMaterialBlock {
|
|
|
75
93
|
* Gets the source input component
|
|
76
94
|
*/
|
|
77
95
|
get source(): NodeMaterialConnectionPoint;
|
|
96
|
+
/**
|
|
97
|
+
* Gets the sourceY input component
|
|
98
|
+
*/
|
|
99
|
+
get sourceY(): NodeMaterialConnectionPoint;
|
|
100
|
+
/**
|
|
101
|
+
* Gets the sourceZ input component
|
|
102
|
+
*/
|
|
103
|
+
get sourceZ(): Nullable<NodeMaterialConnectionPoint>;
|
|
78
104
|
/**
|
|
79
105
|
* Gets the rgba output component
|
|
80
106
|
*/
|
|
@@ -18,7 +18,7 @@ export class TriPlanarBlock extends NodeMaterialBlock {
|
|
|
18
18
|
* Create a new TriPlanarBlock
|
|
19
19
|
* @param name defines the block name
|
|
20
20
|
*/
|
|
21
|
-
constructor(name) {
|
|
21
|
+
constructor(name, hideSourceZ = false) {
|
|
22
22
|
super(name, NodeMaterialBlockTargets.Neutral);
|
|
23
23
|
this._convertToGammaSpace = false;
|
|
24
24
|
this._convertToLinearSpace = false;
|
|
@@ -26,10 +26,14 @@ export class TriPlanarBlock extends NodeMaterialBlock {
|
|
|
26
26
|
* Gets or sets a boolean indicating if multiplication of texture with level should be disabled
|
|
27
27
|
*/
|
|
28
28
|
this.disableLevelMultiplication = false;
|
|
29
|
-
this.registerInput("position", NodeMaterialBlockConnectionPointTypes.
|
|
30
|
-
this.registerInput("normal", NodeMaterialBlockConnectionPointTypes.
|
|
29
|
+
this.registerInput("position", NodeMaterialBlockConnectionPointTypes.AutoDetect, false);
|
|
30
|
+
this.registerInput("normal", NodeMaterialBlockConnectionPointTypes.AutoDetect, false);
|
|
31
31
|
this.registerInput("sharpness", NodeMaterialBlockConnectionPointTypes.Float, true);
|
|
32
32
|
this.registerInput("source", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.VertexAndFragment, new NodeMaterialConnectionPointCustomObject("source", this, NodeMaterialConnectionPointDirection.Input, ImageSourceBlock, "ImageSourceBlock"));
|
|
33
|
+
this.registerInput("sourceY", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.VertexAndFragment, new NodeMaterialConnectionPointCustomObject("sourceY", this, NodeMaterialConnectionPointDirection.Input, ImageSourceBlock, "ImageSourceBlock"));
|
|
34
|
+
if (!hideSourceZ) {
|
|
35
|
+
this.registerInput("sourceZ", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.VertexAndFragment, new NodeMaterialConnectionPointCustomObject("sourceZ", this, NodeMaterialConnectionPointDirection.Input, ImageSourceBlock, "ImageSourceBlock"));
|
|
36
|
+
}
|
|
33
37
|
this.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Neutral);
|
|
34
38
|
this.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Neutral);
|
|
35
39
|
this.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral);
|
|
@@ -37,8 +41,8 @@ export class TriPlanarBlock extends NodeMaterialBlock {
|
|
|
37
41
|
this.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral);
|
|
38
42
|
this.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral);
|
|
39
43
|
this.registerOutput("level", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral);
|
|
40
|
-
this._inputs[0].
|
|
41
|
-
this._inputs[1].
|
|
44
|
+
this._inputs[0].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Color3 | NodeMaterialBlockConnectionPointTypes.Vector3 | NodeMaterialBlockConnectionPointTypes.Vector4);
|
|
45
|
+
this._inputs[1].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Color3 | NodeMaterialBlockConnectionPointTypes.Vector3 | NodeMaterialBlockConnectionPointTypes.Vector4);
|
|
42
46
|
}
|
|
43
47
|
/**
|
|
44
48
|
* Gets or sets the texture associated with the node
|
|
@@ -68,20 +72,58 @@ export class TriPlanarBlock extends NodeMaterialBlock {
|
|
|
68
72
|
});
|
|
69
73
|
}
|
|
70
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Gets the textureY associated with the node
|
|
77
|
+
*/
|
|
78
|
+
get textureY() {
|
|
79
|
+
var _a;
|
|
80
|
+
if (this.sourceY.isConnected) {
|
|
81
|
+
return ((_a = this.sourceY.connectedPoint) === null || _a === void 0 ? void 0 : _a.ownerBlock).texture;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Gets the textureZ associated with the node
|
|
87
|
+
*/
|
|
88
|
+
get textureZ() {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
if ((_a = this.sourceZ) === null || _a === void 0 ? void 0 : _a.isConnected) {
|
|
91
|
+
return ((_b = this.sourceY.connectedPoint) === null || _b === void 0 ? void 0 : _b.ownerBlock).texture;
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
_getImageSourceBlock(connectionPoint) {
|
|
96
|
+
return (connectionPoint === null || connectionPoint === void 0 ? void 0 : connectionPoint.isConnected) ? connectionPoint.connectedPoint.ownerBlock : null;
|
|
97
|
+
}
|
|
71
98
|
/**
|
|
72
99
|
* Gets the sampler name associated with this texture
|
|
73
100
|
*/
|
|
74
101
|
get samplerName() {
|
|
75
|
-
|
|
76
|
-
|
|
102
|
+
const imageSourceBlock = this._getImageSourceBlock(this.source);
|
|
103
|
+
if (imageSourceBlock) {
|
|
104
|
+
return imageSourceBlock.samplerName;
|
|
77
105
|
}
|
|
78
106
|
return this._samplerName;
|
|
79
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Gets the samplerY name associated with this texture
|
|
110
|
+
*/
|
|
111
|
+
get samplerYName() {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
return (_b = (_a = this._getImageSourceBlock(this.sourceY)) === null || _a === void 0 ? void 0 : _a.samplerName) !== null && _b !== void 0 ? _b : null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Gets the samplerZ name associated with this texture
|
|
117
|
+
*/
|
|
118
|
+
get samplerZName() {
|
|
119
|
+
var _a, _b;
|
|
120
|
+
return (_b = (_a = this._getImageSourceBlock(this.sourceZ)) === null || _a === void 0 ? void 0 : _a.samplerName) !== null && _b !== void 0 ? _b : null;
|
|
121
|
+
}
|
|
80
122
|
/**
|
|
81
123
|
* Gets a boolean indicating that this block is linked to an ImageSourceBlock
|
|
82
124
|
*/
|
|
83
125
|
get hasImageSource() {
|
|
84
|
-
return
|
|
126
|
+
return this.source.isConnected;
|
|
85
127
|
}
|
|
86
128
|
/**
|
|
87
129
|
* Gets or sets a boolean indicating if content needs to be converted to gamma space
|
|
@@ -152,6 +194,18 @@ export class TriPlanarBlock extends NodeMaterialBlock {
|
|
|
152
194
|
get source() {
|
|
153
195
|
return this._inputs[3];
|
|
154
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Gets the sourceY input component
|
|
199
|
+
*/
|
|
200
|
+
get sourceY() {
|
|
201
|
+
return this._inputs[4];
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Gets the sourceZ input component
|
|
205
|
+
*/
|
|
206
|
+
get sourceZ() {
|
|
207
|
+
return this._inputs[5];
|
|
208
|
+
}
|
|
155
209
|
/**
|
|
156
210
|
* Gets the rgba output component
|
|
157
211
|
*/
|
|
@@ -220,7 +274,10 @@ export class TriPlanarBlock extends NodeMaterialBlock {
|
|
|
220
274
|
}
|
|
221
275
|
}
|
|
222
276
|
_generateTextureLookup(state) {
|
|
277
|
+
var _a, _b;
|
|
223
278
|
const samplerName = this.samplerName;
|
|
279
|
+
const samplerYName = (_a = this.samplerYName) !== null && _a !== void 0 ? _a : samplerName;
|
|
280
|
+
const samplerZName = (_b = this.samplerZName) !== null && _b !== void 0 ? _b : samplerName;
|
|
224
281
|
const sharpness = this.sharpness.isConnected ? this.sharpness.associatedVariableName : "1.0";
|
|
225
282
|
const x = state._getFreeVariableName("x");
|
|
226
283
|
const y = state._getFreeVariableName("y");
|
|
@@ -228,8 +285,8 @@ export class TriPlanarBlock extends NodeMaterialBlock {
|
|
|
228
285
|
const w = state._getFreeVariableName("z");
|
|
229
286
|
state.compilationString += `
|
|
230
287
|
vec4 ${x} = texture2D(${samplerName}, ${this.position.associatedVariableName}.yz);
|
|
231
|
-
vec4 ${y} = texture2D(${
|
|
232
|
-
vec4 ${z} = texture2D(${
|
|
288
|
+
vec4 ${y} = texture2D(${samplerYName}, ${this.position.associatedVariableName}.zx);
|
|
289
|
+
vec4 ${z} = texture2D(${samplerZName}, ${this.position.associatedVariableName}.xy);
|
|
233
290
|
|
|
234
291
|
// blend weights
|
|
235
292
|
vec3 ${w} = pow(abs(${this.normal.associatedVariableName}.xyz), vec3(${sharpness}));
|