inputBlock.ts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. import { NodeMaterialBlock } from '../../nodeMaterialBlock';
  2. import { NodeMaterialBlockConnectionPointTypes } from '../../Enums/nodeMaterialBlockConnectionPointTypes';
  3. import { NodeMaterialBlockConnectionPointMode } from '../../Enums/nodeMaterialBlockConnectionPointMode';
  4. import { NodeMaterialSystemValues } from '../../Enums/nodeMaterialSystemValues';
  5. import { Nullable } from '../../../../types';
  6. import { Effect } from '../../../../Materials/effect';
  7. import { Matrix, Vector2, Vector3, Vector4 } from '../../../../Maths/math.vector';
  8. import { Scene } from '../../../../scene';
  9. import { NodeMaterialConnectionPoint } from '../../nodeMaterialBlockConnectionPoint';
  10. import { NodeMaterialBuildState } from '../../nodeMaterialBuildState';
  11. import { NodeMaterialBlockTargets } from '../../Enums/nodeMaterialBlockTargets';
  12. import { _TypeStore } from '../../../../Misc/typeStore';
  13. import { Color3, Color4 } from '../../../../Maths/math';
  14. import { AnimatedInputBlockTypes } from './animatedInputBlockTypes';
  15. /**
  16. * Block used to expose an input value
  17. */
  18. export class InputBlock extends NodeMaterialBlock {
  19. private _mode = NodeMaterialBlockConnectionPointMode.Undefined;
  20. private _associatedVariableName: string;
  21. private _storedValue: any;
  22. private _valueCallback: () => any;
  23. private _type: NodeMaterialBlockConnectionPointTypes;
  24. private _animationType = AnimatedInputBlockTypes.None;
  25. /** Gets or set a value used to limit the range of float values */
  26. public min: number = 0;
  27. /** Gets or set a value used to limit the range of float values */
  28. public max: number = 0;
  29. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  30. public matrixMode: number = 0;
  31. /** @hidden */
  32. public _systemValue: Nullable<NodeMaterialSystemValues> = null;
  33. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  34. public visibleInInspector = false;
  35. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  36. public isConstant = false;
  37. /** Gets or sets the group to use to display this block in the Inspector */
  38. public groupInInspector = "";
  39. /**
  40. * Gets or sets the connection point type (default is float)
  41. */
  42. public get type(): NodeMaterialBlockConnectionPointTypes {
  43. if (this._type === NodeMaterialBlockConnectionPointTypes.AutoDetect) {
  44. if (this.isUniform && this.value != null) {
  45. if (!isNaN(this.value)) {
  46. this._type = NodeMaterialBlockConnectionPointTypes.Float;
  47. return this._type;
  48. }
  49. switch (this.value.getClassName()) {
  50. case "Vector2":
  51. this._type = NodeMaterialBlockConnectionPointTypes.Vector2;
  52. return this._type;
  53. case "Vector3":
  54. this._type = NodeMaterialBlockConnectionPointTypes.Vector3;
  55. return this._type;
  56. case "Vector4":
  57. this._type = NodeMaterialBlockConnectionPointTypes.Vector4;
  58. return this._type;
  59. case "Color3":
  60. this._type = NodeMaterialBlockConnectionPointTypes.Color3;
  61. return this._type;
  62. case "Color4":
  63. this._type = NodeMaterialBlockConnectionPointTypes.Color4;
  64. return this._type;
  65. }
  66. }
  67. if (this.isAttribute) {
  68. switch (this.name) {
  69. case "position":
  70. case "normal":
  71. case "tangent":
  72. this._type = NodeMaterialBlockConnectionPointTypes.Vector3;
  73. return this._type;
  74. case "uv":
  75. case "uv2":
  76. this._type = NodeMaterialBlockConnectionPointTypes.Vector2;
  77. return this._type;
  78. case "matricesIndices":
  79. case "matricesWeights":
  80. case "world0":
  81. case "world1":
  82. case "world2":
  83. case "world3":
  84. this._type = NodeMaterialBlockConnectionPointTypes.Vector4;
  85. return this._type;
  86. case "color":
  87. this._type = NodeMaterialBlockConnectionPointTypes.Color4;
  88. return this._type;
  89. }
  90. }
  91. if (this.isSystemValue) {
  92. switch (this._systemValue) {
  93. case NodeMaterialSystemValues.World:
  94. case NodeMaterialSystemValues.WorldView:
  95. case NodeMaterialSystemValues.WorldViewProjection:
  96. case NodeMaterialSystemValues.View:
  97. case NodeMaterialSystemValues.ViewProjection:
  98. case NodeMaterialSystemValues.Projection:
  99. this._type = NodeMaterialBlockConnectionPointTypes.Matrix;
  100. return this._type;
  101. case NodeMaterialSystemValues.CameraPosition:
  102. this._type = NodeMaterialBlockConnectionPointTypes.Vector3;
  103. return this._type;
  104. case NodeMaterialSystemValues.FogColor:
  105. this._type = NodeMaterialBlockConnectionPointTypes.Color3;
  106. return this._type;
  107. case NodeMaterialSystemValues.DeltaTime:
  108. this._type = NodeMaterialBlockConnectionPointTypes.Float;
  109. return this._type;
  110. }
  111. }
  112. }
  113. return this._type;
  114. }
  115. /**
  116. * Creates a new InputBlock
  117. * @param name defines the block name
  118. * @param target defines the target of that block (Vertex by default)
  119. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120. */
  121. public constructor(name: string, target = NodeMaterialBlockTargets.Vertex, type: NodeMaterialBlockConnectionPointTypes = NodeMaterialBlockConnectionPointTypes.AutoDetect) {
  122. super(name, target, false, true);
  123. this._type = type;
  124. this.setDefaultValue();
  125. this.registerOutput("output", type);
  126. }
  127. /**
  128. * Gets the output component
  129. */
  130. public get output(): NodeMaterialConnectionPoint {
  131. return this._outputs[0];
  132. }
  133. /**
  134. * Set the source of this connection point to a vertex attribute
  135. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  136. * @returns the current connection point
  137. */
  138. public setAsAttribute(attributeName?: string): InputBlock {
  139. if (attributeName) {
  140. this.name = attributeName;
  141. }
  142. this._mode = NodeMaterialBlockConnectionPointMode.Attribute;
  143. return this;
  144. }
  145. /**
  146. * Set the source of this connection point to a system value
  147. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  148. * @returns the current connection point
  149. */
  150. public setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock {
  151. this.systemValue = value;
  152. return this;
  153. }
  154. /**
  155. * Gets or sets the value of that point.
  156. * Please note that this value will be ignored if valueCallback is defined
  157. */
  158. public get value(): any {
  159. return this._storedValue;
  160. }
  161. public set value(value: any) {
  162. this._storedValue = value;
  163. this._mode = NodeMaterialBlockConnectionPointMode.Uniform;
  164. }
  165. /**
  166. * Gets or sets a callback used to get the value of that point.
  167. * Please note that setting this value will force the connection point to ignore the value property
  168. */
  169. public get valueCallback(): () => any {
  170. return this._valueCallback;
  171. }
  172. public set valueCallback(value: () => any) {
  173. this._valueCallback = value;
  174. this._mode = NodeMaterialBlockConnectionPointMode.Uniform;
  175. }
  176. /**
  177. * Gets or sets the associated variable name in the shader
  178. */
  179. public get associatedVariableName(): string {
  180. return this._associatedVariableName;
  181. }
  182. public set associatedVariableName(value: string) {
  183. this._associatedVariableName = value;
  184. }
  185. /** Gets or sets the type of animation applied to the input */
  186. public get animationType() {
  187. return this._animationType;
  188. }
  189. public set animationType(value: AnimatedInputBlockTypes) {
  190. this._animationType = value;
  191. }
  192. /**
  193. * Gets a boolean indicating that this connection point not defined yet
  194. */
  195. public get isUndefined(): boolean {
  196. return this._mode === NodeMaterialBlockConnectionPointMode.Undefined;
  197. }
  198. /**
  199. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  200. * In this case the connection point name must be the name of the uniform to use.
  201. * Can only be set on inputs
  202. */
  203. public get isUniform(): boolean {
  204. return this._mode === NodeMaterialBlockConnectionPointMode.Uniform;
  205. }
  206. public set isUniform(value: boolean) {
  207. this._mode = value ? NodeMaterialBlockConnectionPointMode.Uniform : NodeMaterialBlockConnectionPointMode.Undefined;
  208. this.associatedVariableName = "";
  209. }
  210. /**
  211. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  212. * In this case the connection point name must be the name of the attribute to use
  213. * Can only be set on inputs
  214. */
  215. public get isAttribute(): boolean {
  216. return this._mode === NodeMaterialBlockConnectionPointMode.Attribute;
  217. }
  218. public set isAttribute(value: boolean) {
  219. this._mode = value ? NodeMaterialBlockConnectionPointMode.Attribute : NodeMaterialBlockConnectionPointMode.Undefined;
  220. this.associatedVariableName = "";
  221. }
  222. /**
  223. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  224. * Can only be set on exit points
  225. */
  226. public get isVarying(): boolean {
  227. return this._mode === NodeMaterialBlockConnectionPointMode.Varying;
  228. }
  229. public set isVarying(value: boolean) {
  230. this._mode = value ? NodeMaterialBlockConnectionPointMode.Varying : NodeMaterialBlockConnectionPointMode.Undefined;
  231. this.associatedVariableName = "";
  232. }
  233. /**
  234. * Gets a boolean indicating that the current connection point is a system value
  235. */
  236. public get isSystemValue(): boolean {
  237. return this._systemValue != null;
  238. }
  239. /**
  240. * Gets or sets the current well known value or null if not defined as a system value
  241. */
  242. public get systemValue(): Nullable<NodeMaterialSystemValues> {
  243. return this._systemValue;
  244. }
  245. public set systemValue(value: Nullable<NodeMaterialSystemValues>) {
  246. this._mode = NodeMaterialBlockConnectionPointMode.Uniform;
  247. this.associatedVariableName = "";
  248. this._systemValue = value;
  249. }
  250. /**
  251. * Gets the current class name
  252. * @returns the class name
  253. */
  254. public getClassName() {
  255. return "InputBlock";
  256. }
  257. /**
  258. * Animate the input if animationType !== None
  259. * @param scene defines the rendering scene
  260. */
  261. public animate(scene: Scene) {
  262. switch (this._animationType) {
  263. case AnimatedInputBlockTypes.Time: {
  264. if (this.type === NodeMaterialBlockConnectionPointTypes.Float) {
  265. this.value += scene.getAnimationRatio() * 0.01;
  266. }
  267. break;
  268. }
  269. }
  270. }
  271. private _emitDefine(define: string): string {
  272. if (define[0] === "!") {
  273. return `#ifndef ${define.substring(1)}\r\n`;
  274. }
  275. return `#ifdef ${define}\r\n`;
  276. }
  277. public initialize(state: NodeMaterialBuildState) {
  278. this.associatedVariableName = "";
  279. }
  280. /**
  281. * Set the input block to its default value (based on its type)
  282. */
  283. public setDefaultValue() {
  284. switch (this.type) {
  285. case NodeMaterialBlockConnectionPointTypes.Float:
  286. this.value = 0;
  287. break;
  288. case NodeMaterialBlockConnectionPointTypes.Vector2:
  289. this.value = Vector2.Zero();
  290. break;
  291. case NodeMaterialBlockConnectionPointTypes.Vector3:
  292. this.value = Vector3.Zero();
  293. break;
  294. case NodeMaterialBlockConnectionPointTypes.Vector4:
  295. this.value = Vector4.Zero();
  296. break;
  297. case NodeMaterialBlockConnectionPointTypes.Color3:
  298. this.value = Color3.White();
  299. break;
  300. case NodeMaterialBlockConnectionPointTypes.Color4:
  301. this.value = new Color4(1, 1, 1, 1);
  302. break;
  303. case NodeMaterialBlockConnectionPointTypes.Matrix:
  304. this.value = Matrix.Identity();
  305. break;
  306. }
  307. }
  308. private _emitConstant(state: NodeMaterialBuildState) {
  309. switch (this.type) {
  310. case NodeMaterialBlockConnectionPointTypes.Float:
  311. return `${state._emitFloat(this.value)}`;
  312. case NodeMaterialBlockConnectionPointTypes.Vector2:
  313. return `vec2(${this.value.x}, ${this.value.y})`;
  314. case NodeMaterialBlockConnectionPointTypes.Vector3:
  315. return `vec3(${this.value.x}, ${this.value.y}, ${this.value.z})`;
  316. case NodeMaterialBlockConnectionPointTypes.Vector4:
  317. return `vec4(${this.value.x}, ${this.value.y}, ${this.value.z}, ${this.value.w})`;
  318. case NodeMaterialBlockConnectionPointTypes.Color3:
  319. return `vec3(${this.value.r}, ${this.value.g}, ${this.value.b})`;
  320. case NodeMaterialBlockConnectionPointTypes.Color4:
  321. return `vec4(${this.value.r}, ${this.value.g}, ${this.value.b}, ${this.value.a})`;
  322. }
  323. return "";
  324. }
  325. private _emit(state: NodeMaterialBuildState, define?: string) {
  326. // Uniforms
  327. if (this.isUniform) {
  328. if (!this.associatedVariableName) {
  329. this.associatedVariableName = state._getFreeVariableName("u_" + this.name);
  330. }
  331. if (this.isConstant) {
  332. if (state.constants.indexOf(this.associatedVariableName) !== -1) {
  333. return;
  334. }
  335. state.constants.push(this.associatedVariableName);
  336. state._constantDeclaration += this._declareOutput(this.output, state) + ` = ${this._emitConstant(state)};\r\n`;
  337. return;
  338. }
  339. if (state.uniforms.indexOf(this.associatedVariableName) !== -1) {
  340. return;
  341. }
  342. state.uniforms.push(this.associatedVariableName);
  343. if (define) {
  344. state._uniformDeclaration += this._emitDefine(define);
  345. }
  346. state._uniformDeclaration += `uniform ${state._getGLType(this.type)} ${this.associatedVariableName};\r\n`;
  347. if (define) {
  348. state._uniformDeclaration += `#endif\r\n`;
  349. }
  350. // well known
  351. let hints = state.sharedData.hints;
  352. if (this._systemValue !== null && this._systemValue !== undefined) {
  353. switch (this._systemValue) {
  354. case NodeMaterialSystemValues.WorldView:
  355. hints.needWorldViewMatrix = true;
  356. break;
  357. case NodeMaterialSystemValues.WorldViewProjection:
  358. hints.needWorldViewProjectionMatrix = true;
  359. break;
  360. }
  361. } else {
  362. if (this._animationType !== AnimatedInputBlockTypes.None) {
  363. state.sharedData.animatedInputs.push(this);
  364. }
  365. }
  366. return;
  367. }
  368. // Attribute
  369. if (this.isAttribute) {
  370. this.associatedVariableName = this.name;
  371. if (this.target === NodeMaterialBlockTargets.Vertex && state._vertexState) { // Attribute for fragment need to be carried over by varyings
  372. this._emit(state._vertexState, define);
  373. return;
  374. }
  375. if (state.attributes.indexOf(this.associatedVariableName) !== -1) {
  376. return;
  377. }
  378. state.attributes.push(this.associatedVariableName);
  379. if (define) {
  380. state._attributeDeclaration += this._emitDefine(define);
  381. }
  382. state._attributeDeclaration += `attribute ${state._getGLType(this.type)} ${this.associatedVariableName};\r\n`;
  383. if (define) {
  384. state._attributeDeclaration += `#endif\r\n`;
  385. }
  386. }
  387. }
  388. /** @hidden */
  389. public _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix) {
  390. if (!this._systemValue) {
  391. return;
  392. }
  393. let variableName = this.associatedVariableName;
  394. switch (this._systemValue) {
  395. case NodeMaterialSystemValues.World:
  396. effect.setMatrix(variableName, world);
  397. break;
  398. case NodeMaterialSystemValues.WorldView:
  399. effect.setMatrix(variableName, worldView);
  400. break;
  401. case NodeMaterialSystemValues.WorldViewProjection:
  402. effect.setMatrix(variableName, worldViewProjection);
  403. break;
  404. }
  405. }
  406. /** @hidden */
  407. public _transmit(effect: Effect, scene: Scene) {
  408. if (this.isAttribute) {
  409. return;
  410. }
  411. let variableName = this.associatedVariableName;
  412. if (this._systemValue) {
  413. switch (this._systemValue) {
  414. case NodeMaterialSystemValues.World:
  415. case NodeMaterialSystemValues.WorldView:
  416. case NodeMaterialSystemValues.WorldViewProjection:
  417. return;
  418. case NodeMaterialSystemValues.View:
  419. effect.setMatrix(variableName, scene.getViewMatrix());
  420. break;
  421. case NodeMaterialSystemValues.Projection:
  422. effect.setMatrix(variableName, scene.getProjectionMatrix());
  423. break;
  424. case NodeMaterialSystemValues.ViewProjection:
  425. effect.setMatrix(variableName, scene.getTransformMatrix());
  426. break;
  427. case NodeMaterialSystemValues.CameraPosition:
  428. effect.setVector3(variableName, scene.activeCamera!.globalPosition);
  429. break;
  430. case NodeMaterialSystemValues.FogColor:
  431. effect.setColor3(variableName, scene.fogColor);
  432. break;
  433. case NodeMaterialSystemValues.DeltaTime:
  434. effect.setFloat(variableName, scene.deltaTime / 1000.0);
  435. }
  436. return;
  437. }
  438. let value = this._valueCallback ? this._valueCallback() : this._storedValue;
  439. if (value === null) {
  440. return;
  441. }
  442. switch (this.type) {
  443. case NodeMaterialBlockConnectionPointTypes.Float:
  444. effect.setFloat(variableName, value);
  445. break;
  446. case NodeMaterialBlockConnectionPointTypes.Int:
  447. effect.setInt(variableName, value);
  448. break;
  449. case NodeMaterialBlockConnectionPointTypes.Color3:
  450. effect.setColor3(variableName, value);
  451. break;
  452. case NodeMaterialBlockConnectionPointTypes.Color4:
  453. effect.setDirectColor4(variableName, value);
  454. break;
  455. case NodeMaterialBlockConnectionPointTypes.Vector2:
  456. effect.setVector2(variableName, value);
  457. break;
  458. case NodeMaterialBlockConnectionPointTypes.Vector3:
  459. effect.setVector3(variableName, value);
  460. break;
  461. case NodeMaterialBlockConnectionPointTypes.Vector4:
  462. effect.setVector4(variableName, value);
  463. break;
  464. case NodeMaterialBlockConnectionPointTypes.Matrix:
  465. effect.setMatrix(variableName, value);
  466. break;
  467. }
  468. }
  469. protected _buildBlock(state: NodeMaterialBuildState) {
  470. super._buildBlock(state);
  471. if (this.isUniform || this.isSystemValue) {
  472. state.sharedData.inputBlocks.push(this);
  473. }
  474. this._emit(state);
  475. }
  476. protected _dumpPropertiesCode() {
  477. let variableName = this._codeVariableName;
  478. if (this.isAttribute) {
  479. return `${variableName}.setAsAttribute("${this.name}");\r\n`;
  480. }
  481. if (this.isSystemValue) {
  482. return `${variableName}.setAsSystemValue(BABYLON.NodeMaterialSystemValues.${NodeMaterialSystemValues[this._systemValue!]});\r\n`;
  483. }
  484. if (this.isUniform) {
  485. let valueString = "";
  486. switch (this.type) {
  487. case NodeMaterialBlockConnectionPointTypes.Float:
  488. let returnValue = `${variableName}.value = ${this.value};\r\n`;
  489. returnValue += `${variableName}.min = ${this.min};\r\n`;
  490. returnValue += `${variableName}.max = ${this.max};\r\n`;
  491. returnValue += `${variableName}.matrixMode = ${this.matrixMode};\r\n`;
  492. returnValue += `${variableName}.animationType = BABYLON.AnimatedInputBlockTypes.${AnimatedInputBlockTypes[this.animationType]};\r\n`;
  493. return returnValue;
  494. case NodeMaterialBlockConnectionPointTypes.Vector2:
  495. valueString = `new BABYLON.Vector2(${this.value.x}, ${this.value.y})`;
  496. break;
  497. case NodeMaterialBlockConnectionPointTypes.Vector3:
  498. valueString = `new BABYLON.Vector3(${this.value.x}, ${this.value.y}, ${this.value.z})`;
  499. break;
  500. case NodeMaterialBlockConnectionPointTypes.Vector4:
  501. valueString = `new BABYLON.Vector4(${this.value.x}, ${this.value.y}, ${this.value.z}, ${this.value.w})`;
  502. break;
  503. case NodeMaterialBlockConnectionPointTypes.Color3:
  504. valueString = `new BABYLON.Color3(${this.value.r}, ${this.value.g}, ${this.value.b})`;
  505. break;
  506. case NodeMaterialBlockConnectionPointTypes.Color4:
  507. valueString = `new BABYLON.Color4(${this.value.r}, ${this.value.g}, ${this.value.b}, ${this.value.a})`;
  508. break;
  509. }
  510. let finalOutput = `${variableName}.value = ${valueString};\r\n`;
  511. finalOutput += `${variableName}.isConstant = ${this.isConstant ? "true" : "false"};\r\n`;
  512. finalOutput += `${variableName}.visibleInInspector = ${this.visibleInInspector ? "true" : "false"};\r\n`;
  513. return finalOutput;
  514. }
  515. return "";
  516. }
  517. public serialize(): any {
  518. let serializationObject = super.serialize();
  519. serializationObject.type = this.type;
  520. serializationObject.mode = this._mode;
  521. serializationObject.systemValue = this._systemValue;
  522. serializationObject.animationType = this._animationType;
  523. serializationObject.visibleInInspector = this.visibleInInspector;
  524. serializationObject.min = this.min;
  525. serializationObject.max = this.max;
  526. serializationObject.matrixMode = this.matrixMode;
  527. serializationObject.isConstant = this.isConstant;
  528. serializationObject.groupInInspector = this.groupInInspector;
  529. if (this._storedValue != null && this._mode === NodeMaterialBlockConnectionPointMode.Uniform) {
  530. if (this._storedValue.asArray) {
  531. serializationObject.valueType = "BABYLON." + this._storedValue.getClassName();
  532. serializationObject.value = this._storedValue.asArray();
  533. } else {
  534. serializationObject.valueType = "number";
  535. serializationObject.value = this._storedValue;
  536. }
  537. }
  538. return serializationObject;
  539. }
  540. public _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {
  541. super._deserialize(serializationObject, scene, rootUrl);
  542. this._type = serializationObject.type;
  543. this._mode = serializationObject.mode;
  544. this._systemValue = serializationObject.systemValue || serializationObject.wellKnownValue;
  545. this._animationType = serializationObject.animationType;
  546. this.visibleInInspector = serializationObject.visibleInInspector;
  547. this.min = serializationObject.min || 0;
  548. this.max = serializationObject.max || 0;
  549. this.matrixMode = serializationObject.matrixMode || 0;
  550. this.isConstant = !!serializationObject.isConstant;
  551. this.groupInInspector = serializationObject.groupInInspector || "";
  552. if (!serializationObject.valueType) {
  553. return;
  554. }
  555. if (serializationObject.valueType === "number") {
  556. this._storedValue = serializationObject.value;
  557. } else {
  558. let valueType = _TypeStore.GetClass(serializationObject.valueType);
  559. if (valueType) {
  560. this._storedValue = valueType.FromArray(serializationObject.value);
  561. }
  562. }
  563. }
  564. }
  565. _TypeStore.RegisteredTypes["BABYLON.InputBlock"] = InputBlock;